If this request has been forwarded using RequestDispatcher.forward(ServletRequest, ServletResponse) , the server path in the reconstructed URL must reflect the path used to obtain the RequestDispatcher, and not the server path specified by the client. Because this method returns a StringBuffer , not a string, you can modify the URL easily, for example, to append query parameters.
session has been expired, unfortunately, the HttpSession.getId() method is often used in this scenario and is supposed to throw an IllegalStateException. The servlet EG agreed to remove the exception from the API to prevent these types of exceptions.
Returns the context path of the web application. The context path is the portion of the request URI that is used to select the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "".
It is possible that a servlet container may match a context by more than one context path. In such cases getContextPath() will return the actual context path used by the request and it may differ from the path returned by this method. The context path returned by this method should be considered as the prime or preferred context path of the application.
It is possible that a servlet container may match a context by more than one context path. In such cases this method will return the actual context path used by the request and it may differ from the path returned by the ServletContext.getContextPath() method. The context path returned by ServletContext.getContextPath() should be considered as the prime or preferred context path of the application.
A web application is NOT required to contain a web.xml if it does NOT contain any Servlet, Filter, or Listener components. In other words an application containing only static files or JSP pages does not require a web.xml does not need to be present.