• jQuery
  • RubyonRails
  • Struts
  • Servlet
  • PHP
  • JavaScript
  • SQL Tutorial
  • Core Java
  • Java IO

  • <

    Response in JSP


    A Reponse is sent to client (broswer) by the server. Jsp Response is a implicit object of javax.servlet.http.HttpServletResponse . The response object is response for creating new HTTP headers.


    Methods of Jsp Response Object


  • response.setContentType("text/html")
  • Set Content type text/html.

  • response.sendRedirect(String address)
  • It will redirect by specified URL.

  • response.addHeader(String name, String value)
  • Response add header name and value.

  • response.setHeader(String name, String value)
  • Response set header name and value.

  • boolean containsHeader(String name)
  • Check whether header already set.

  • response.addCookie(Cookie value)
  • Response add cookie.

  • response.sendError(int status_code, String message)
  • Set response error code and error message

  • boolean isCommitted()
  • Checks whether it is sent or not to the client.

  • response.setStatus(int statuscode)
  • Set status code for the response.


    Jsp Response Example


    In this example we will create jsp response sendRedirect application. when you run index.jsp in localhost it will redirect to http://www.protutorialplus.com.

    index.jsp
    
    <%   
    response.sendRedirect("http://www.protutorialplus.com");  
    %>  
    
    
















    © copyright 2017-2021 Completedone pvt ltd.