KickJava   Java API By Example, From Geeks To Geeks.

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

javax.servlet.http
Interface HttpServletResponse

All Superinterfaces:
ServletResponse
All Known Implementing Classes:
HttpServletResponseWrapper
See Also:
Top Examples, Source Code

public void addCookie(Cookie cookie)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[193]Perfoming a redirect
By Anonymous on 2003/07/30 10:21:14  Rate
String redirectStr = contextPath + "/KickJava.jsp?username=foo&password=bar"; 
  
  
 // Always call the encodeRedirectURL method when perfoming a redirect 
 resp.sendRedirect ( resp.encodeRedirectURL ( redirectStr )  ) ; 
  
  
 //addCookie


[467]Read write cookie
By azizulislamrobel { at } hotmail { dot } com on 2003/10/22 04:52:36  Rate
//***************Code for color. ( user submit )   
  
  
 import javax.servlet.*; 
 import javax.servlet.http.*; 
 import java.io.*; 
 import java.util.*; 
 import java.sql.*; 
  
  
 public class Color extends HttpServlet 
  {  
   public void service ( HttpServletRequest req, HttpServletResponse res )  throws IOException 
    {  
     boolean cookieFound=false; 
     Cookie myCookie=null; 
     Cookie [  ]  cookieset=req.getCookies (  ) ; 
     res.setContentType ( "text/html" ) ; 
     PrintWriter pw=res.getWriter (  ) ; 
  
  
     String bgc=req.getParameter ( "bgc" ) ; 
     pw.println ( " < html > " ) ; 
     pw.println ( " < body bgcolor=" +bgc+ " > " ) ; 
     pw.println ( " < form method='POST' action='http://172.17.8.57:8000/Color/Color' > " ) ; 
     pw.println ( " Enter Color Name : < input type='text' name='bgc' >  < br >  < input type='submit' value='Submit' name='B1' > " ) ; 
     pw.println ( " < /form > " ) ; 
     /*for  ( int i=0;i < cookieset.length;i++ )  
      {  
       if ( cookieset [ i ] .getName (  ) .equals ( "logincount" )  )  
        {  
         cookieFound=true; 
         myCookie=cookieset [ i ] ; 
        }  
      }  
     if ( cookieFound )  
      {  
       int temp=Integer.parseInt ( myCookie.getValue (  )  ) ; 
       temp++; 
       if ( temp==5 )  
       pw.println ( "Congratulations !!!!!" ) ; 
       pw.println ( "The number of times you have logged in is :"+String.valueOf ( temp )  ) ; 
       myCookie.setValue ( String.valueOf ( temp )  ) ; 
       int age=60*60*24*30; 
       myCookie.setMaxAge ( age ) ; 
       res.addCookie ( myCookie ) ; 
       cookieFound=false; 
      }  
     else 
      {  
       int temp=1; 
       pw.println ( "This is the first time you have logged on tothe server" ) ; 
       myCookie=new Cookie ( "logincount",String.valueOf ( temp )  ) ; 
       int age=60*60*24; 
       myCookie.setMaxAge ( age ) ; 
       res.addCookie ( myCookie ) ; 
      } */
 
     pw.println ( " < /body > " ) ; 
     pw.println ( " < /html > " ) ; 
    }  
  }  
  
  
  
 


public void addDateHeader(String name,
                          long date)
See Also:
setDateHeader(java.lang.String, long)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void addHeader(String name,
                      String value)
See Also:
setHeader(java.lang.String, java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void addIntHeader(String name,
                         int value)
See Also:
setIntHeader(java.lang.String, int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


public void sendError(int sc)
               throws IOException
See Also:
IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void sendError(int sc,
                      String msg)
               throws IOException
See Also:
IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void sendRedirect(String location)
                  throws IOException
See Also:
IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setDateHeader(String name,
                          long date)
See Also:
addDateHeader(java.lang.String, long), containsHeader(java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setHeader(String name,
                      String value)
See Also:
addHeader(java.lang.String, java.lang.String), containsHeader(java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setIntHeader(String name,
                         int value)
See Also:
addIntHeader(java.lang.String, int), containsHeader(java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setStatus(int sc)
See Also:
sendError(int, java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setStatus(int sc,
                      String sm)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags