Showing posts with label request. Show all posts
Showing posts with label request. Show all posts

Wednesday, February 20, 2013

HTTP GET and POST requests – differences and advantages

GET requests:
  • the parameters are put in the URL string;
  • there is limitations for URL string length (something as 4000 bytes), so huge data cannot be passed this way;
  • the generated page is suitable for search engine optimization;
  • not recommended for sending password (and other sensitive data), because it could be seen in the URL and will exists in browser history;
  • sending files in GET requests is not possible;

POST requests:
  • huge data could be passed this way;
  • suitable for sending passwords;
  • POST requests are never cached;
  • cannot be bookmarked;


Tuesday, March 29, 2011

java HttpRequest

The interface HttpRequest is located in package javax.servlet.http.

Here are some important members:
* Cookie[] getCookies()
* String getHeader(java.lang.String name) - Returns the value of the specified request header as a String
* String getMethod() - GET, POST, or PUT
* String getQueryString() - Returns the query string that is contained in the request URL after the path.
* String getRemoteUser() - Returns the login of the user making this request, if the user has been authenticated;
* String getRequestURI() - Returns the part of this request's URL from the protocol name up to the query string;
* StringBuffer getRequestURL() - Reconstructs the URL the client used to make the request;
* HttpSession getSession( boolean create );
* boolean isUserInRole( String role );

----
And some inherited from javax.servlet.http.Request:
* Object getAttribute( String name );
* Enumeration getAttributeNames();
* String getContentType() - Returns the MIME type of the body of the request;
* String getParameter( String name );
* Enumeration getParameterNames();
* String getServerName();
* int getServerPort();
* String getRemoteHost() - Returns the fully qualified name of the client ( or the last proxy that sent the request);
* setAttribute( String name, Object o);
* removeAttribute(java.lang.String name);
* Locale getLocale();