KickJava   Java API By Example, From Geeks To Geeks.

Java > Java SE, EE, ME > javax > servlet > ServletResponse

javax.servlet
Interface ServletResponse

All Known Subinterfaces:
HttpServletResponse
All Known Implementing Classes:
HttpServletResponseWrapper, ServletResponseWrapper
See Also:
Top Examples, Source Code, setLocale(java.util.Locale), setContentType(java.lang.String), setCharacterEncoding(java.lang.String), getWriter(), getOutputStream(), ServletOutputStream

public void flushBuffer()
                 throws IOException
See Also:
reset(), isCommitted(), getBufferSize(), setBufferSize(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public int getBufferSize()
See Also:
reset(), isCommitted(), flushBuffer(), setBufferSize(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getCharacterEncoding()
See Also:
setLocale(java.util.Locale), setContentType(java.lang.String), setCharacterEncoding(java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public String getContentType()
See Also:
getCharacterEncoding(), setContentType(java.lang.String)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public Locale getLocale()
See Also:
setLocale(java.util.Locale)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public ServletOutputStream getOutputStream()
                                    throws IOException
See Also:
getWriter(), IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[1516]Download a file
By Anonymous on 2005/08/15 14:56:47  Rate
//download a file 
  
  
 File file = new File ( archiveUri ) ; 
 FileInputStream fileIn = new FileInputStream ( file ) ; 
 OutputStream out = response.getOutputStream (  ) ; 
 out.setContentType ( "application/octet" ) ; 
 out.setContentLength (  ( int )  file.length (  )  ) ; 
   
 byte [  ]  buffer = new byte [ 2048 ] ; 
 int bytesRead = fileIn.read ( buffer ) ; 
 while  ( bytesRead  > = 0 )   {  
   if  ( bytesRead  >  0 )  
     out.write ( buffer, 0, bytesRead ) ; 
     bytesRead = in.read ( buffer ) ; 
  }  
 out.flush (  ) ; 
 out.close (  ) ; 
 in.close (  ) ; 
 


[1965]close() on output stream?
By ankon on 2008/05/09 07:48:03  Rate
It's not clear that one needs to/should call close (  )  on the output stream. Docs say 'flush (  )  commits'.

public PrintWriter getWriter()
                      throws IOException
See Also:
setCharacterEncoding(java.lang.String), getOutputStream(), IllegalStateException, UnsupportedEncodingException, getCharacterEncoding()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public boolean isCommitted()
See Also:
reset(), flushBuffer(), getBufferSize(), setBufferSize(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void reset()
See Also:
isCommitted(), flushBuffer(), getBufferSize(), setBufferSize(int), IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void resetBuffer()
See Also:
reset(), isCommitted(), getBufferSize(), setBufferSize(int)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setBufferSize(int size)
See Also:
reset(), isCommitted(), flushBuffer(), getBufferSize(), IllegalStateException
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setCharacterEncoding(String charset)
See Also:
#setLocale, setLocale(java.util.Locale)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setContentLength(int len)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


public void setContentType(String type)
See Also:
getWriter(), getOutputStream(), setCharacterEncoding(java.lang.String), setLocale(java.util.Locale)
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  


[158]JSP to generate an Excel Spreadsheet and diplay web page contents
By Anonymous on 2003/01/30 09:35:40  Rate
//JSP to generate an Excel Spreadsheet and diplay web page contents 
  
  
 private static String CONTENT_TYPE = ""; 
    
 // Check what they want 
 if  ( req.getParameter ( "content-type" )  != null )  
  {  
    if  ( req.getParameter ( "content-type" ) .equals ( "excel" )  )  
        CONTENT_TYPE = "application/vnd.ms-excel"; 
    else 
        CONTENT_TYPE = "text/html"; 
  }  
  
  
 res.setContentType ( CONTENT_TYPE ) ; 
 . 
 . 
 . 
 


public void setLocale(Locale loc)
See Also:
setCharacterEncoding(java.lang.String), setContentType(java.lang.String), getLocale()
Geek's Notes:
Description  Add your codes or notes  Search More Java Examples  

Popular Tags