in this period I am studying the Spring MVC showcase example dowlodable from STS dashboard
In my home.jsp view I have the following link:
<a id="request" class="textLink" href="<c:url value="/data/standard/request" />">Request arguments</a>
This link generate an HTTP Request towards the URL: “/data/standard/request”
This is the method of my controller class that handles this HTTP Request:
@RequestMapping(value="/data/standard/request", method=RequestMethod.GET)
public @ResponseBody String standardRequestArgs(HttpServletRequest request, Principal user, Locale locale) {
StringBuilder buffer = new StringBuilder(); // Rappresenta un buffer (sequenza mutabile di caratteri) API compatibile con StreamBuffer
buffer.append("request = ").append(request).append(", ");
buffer.append("userPrincipal = ").append(user).append(", ");
buffer.append("requestLocale = ").append(locale);
return buffer.toString();
}
This method take 3 parameter and I have not clear some of these:
- HttpServletRequest request: Reading the javadoc I can read that this object: Extends the ServletRequest interface to provide request information for HTTP servlets but: what kind of information?
The buffer content related to this object is: request = org.apache.catalina.connector.RequestFacade@62c77dc3 what exactly means?
- Principal user: Reading the javadoc I can read that this object: *This interface represents the abstract notion of a principal, which can be used to represent any entity, such as an individual, a corporation, and a login id. *
I have not clear what exactly can I put in this object and why the related content in the buffers is null
Someone can help me?
thanks
Andrea
HttpServletRequest : Object that is filled by Container. The object is filled by the servlet container i.e. your server which may be tomcat , weblogic . The object contains the information of request parameters, session information. You have little control over this object.
Principal user : User which has logged into your container for accessing the application. If you have added security in the container then the object will give you details for the user who has logged into: User Name, Roles (reals informations.)
Locale locale : The locale of the user accessing your web application.
As far as the response for StringBuffer is concerned, the reference to an object of HttpServletRequest is printed. The object is filled by the servlet container.