- getRequestURL //full URL in type of StringBuffer: "http://localhost:8080/webapp/servlet1"
- getRequestURI //full URL in type of String: "/webapp/servlet1"
- getQueryString //all parameters string "name=abc&email=abc@gvace.com"
- getRemoteAddr //client IP address
- getRemoteHost //client host name if is registered in DNS server, return IP if not registered
- getRemotePort //client connection port
- getLocalPort //return server port "8080"
- getLocalAddr //web server IP address
- getLocalName //web server name
- getHeader("Host") //
- getHeaders() //return Enumeration
- getHeaderNames() //return Enumeration
- getParameter()
- getParameterValues(String name) // return String[], return null if no input
- getParameterNames()
Request Forward
- request.getRequestDispatcher("/servlet1").forward(request,response);
//forward to another servlet within webapp, share the same request and response
//forward url can be only within the same webapp, so no "webapp" directory needed
//keeping the same URL in browser
//different from response.sendRedirect("/webapp/servlet1"); using different request/response
//after the getRequestDispatcher("/servlet1").forward(request,response), all code continues to run, so make sure to return and finish the service
No comments:
Post a Comment