KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > servlet > http > HttpServletRequest

javax.servlet.http
Interface HttpServletRequest

All Superinterfaces:
ServletRequest
All Known Implementing Classes:
HttpServletRequestWrapper
See Also:
Top Examples, Source Code

public static final String BASIC_AUTH
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[180]Interpret the request
By Anonymous on 2005/05/11 13:02:30  Rate
public void doPost ( HttpServletRequest req, 
   HttpServletResponse resp )  throws IOException, ServletException  {  
   /* Interpret the request. */ 
   DataInputStream in = 
   new DataInputStream ( req.getInputStream (  )  ) ; 
   int command = in.readInt (  ) ; 
   resp.setContentType ( "application/binary" ) ; 
   DataOutputStream out = 
   new DataOutputStream ( resp.getOutputStream (  )  ) ; 
   byte command = in.read (  ) ; 
   switch  ( command )   {  
     case LOGIN_USER: 
       String username = in.readUTF (  ) ; 
       String password = in.readUTF (  ) ; 
       /* Check username and password against user database... */ 
    }  
  }  
  
  
 //BASIC_AUTH


public static final String CLIENT_CERT_AUTH
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String DIGEST_AUTH
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public static final String FORM_AUTH
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getAuthType()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getContextPath()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Cookie[] getCookies()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public long getDateHeader(String name)
See Also:
IllegalArgumentException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getHeader(String name)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[201]Get browser language preference (obtained via http header)
By Anonymous on 2003/03/26 15:56:56  Rate
// 
 // Put a Locale object in the user's 
 // session describing the Locale that 
 // is specified by the browser's language preference  ( obtained via http header ) . 
 // 
 String lang = request.getHeader ( "Accept-Language" ) ; 
 if  ( lang != null )  
  {  
   if  ( lang.length (  )   > = 2 )  
    {  
      session.putValue ( org.apache.struts.action.Action.LOCALE_KEY, new java.util.Locale ( lang.substring ( 0, 2 ) , "" )   ) ; 
      % >  < bean:message key="hello.message" / >  < % 
    }  
  }  
 


public Enumeration getHeaderNames()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Enumeration getHeaders(String name)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getIntHeader(String name)
See Also:
NumberFormatException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getMethod()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getPathInfo()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getPathTranslated()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getQueryString()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getRemoteUser()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getRequestedSessionId()
See Also:
isRequestedSessionIdValid()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getRequestURI()
See Also:
HttpUtils.getRequestURL(javax.servlet.http.HttpServletRequest)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public StringBuffer getRequestURL()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1825]getRequestURL returns the JSP file
By Anonymous on 2006/09/27 03:55:15  Rate
request.getRequestURL returns the JSP file instead of Servlet

public String getServletPath()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public HttpSession getSession()
See Also:
getSession(boolean)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public HttpSession getSession(boolean create)
See Also:
getSession()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[190]Invalidate existing session
By Anonymous on 2003/03/26 08:52:00  Rate
// Invalidate existing session if it exists 
 HttpSession session = request.getSession ( false ) ; 
 if ( session != null )   {  
    session.invalidate (  ) ; 
  }  
  
  
 // Create a new session for this user 
 session = request.getSession ( true ) ;


[1969]What is the difference between request.getSession(true) and request.getSession()
By Anonymous on 2008/06/03 08:05:45  Rate
request.getSession (  )  will return the current session and if one does not exist, a new session will be cretaed. 
  
  
 request.getSession ( true )  will return the current session if one exists, if one doesn't exits a new one will be created. 
  
  
 So there is actually no difference between the two methods HOWEVER, if you use request.getSession ( false ) , it will return the current session if one exists and if one DOES NOT exist a new one will NOT be cretaed.


public Principal getUserPrincipal()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isRequestedSessionIdFromCookie()
See Also:
getSession(boolean)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isRequestedSessionIdFromUrl()
See Also:
isRequestedSessionIdFromURL()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isRequestedSessionIdValid()
See Also:
HttpSessionContext, getSession(boolean), getRequestedSessionId()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isUserInRole(String role)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags