Many time encountered with trying to get servlet context, url, path , port number.
This is for reference.
Window Url:
http://localhost:8080/mycomp/myservlet?something=nothing
- request.getRequestURL().toString()
http://localhost:8080/mycomp/myservlet?something=nothing
- request.getContextPath().toString();
/mycomp
---------url.split(cntxt)[0]---------http://localhost:8080
----request.getProtocol()---------HTTP/1.1
----request.getServletPath()---------/myservlet
----request.getRemoteHost()--------0:0:0:0:0:0:0:1
---------url.split(cntxt)[0]---------http://localhost:8080
No comments:
Post a Comment