Difference between jsp forward and sendRedirect

Difference between jsp forward and sendRedirect

What is difference between jsp forward and send Redirect?

View Answers

February 25, 2008 at 1:43 PM

Difference between jsp forward and sendRedirect

JSP forward action (<jsp: forward/>)

jsp forward action transfers the control to a static or dynamic resource. The static or dynamic resource to which control is transferred is represented as a URL. The user can forward the control to an HTML file, another JSP file, or a servlet. It should be noted that the target file must be in the same application context as the forwarding JSP file.

sendRedirect

sendRedirect() method of a response object sends the url to the browser that includes the parameter of sendRedirect() method Browser treats this a new request from the client. sendRedirect() forwards a requests to a resource outside of the current web application. Using sendRedirect is similar to open a new browser and type your url. A sendRedirect() also updates the browser history and transfers control only when the whole service method completes. There is only one way to pass data is through the session or using web parameters (url?name=value).

February 25, 2008 at 1:49 PM


See the difference between sendRedirect() method and jsp:forward in JSP

SendRedirect() - This is the method of HttpServletResponse interface.
Used for sending error codes to browser.
See examples here http://www.roseindia.net/jsp/simple-jsp-example/sendredirect.shtml

Where as
<jsp:forward>
is used to forwards a client request to an HTML file, JSP file, or servlet for processing.
See examples and details here http://roseindia.net/jsp/simple-jsp-example/forward-a-jsp-page.shtml

Meeya









Related Tutorials/Questions & Answers:
Difference between forward and sendRedirect
Difference between forward and sendRedirect  What's the difference between forward and sendRedirect?   RequestDispatcher.forward... to another jsp or servlet. sendRedirect() is more flexible than forward
RequestDispatcher object, difference between include( ) and forward( ) method.
RequestDispatcher object, difference between include( ) and forward( ) method.  The RequestDispatcher object has two methods, include( ) and forward( ). What is the difference
Advertisements
Difference between JSP and Servlets
Difference between JSP and Servlets  What is the difference between JSP and Servlets ?   JSP is used mainly for presentation only. A JSP can only be HttpServlet that means the only supported protocol in JSP is HTTP
difference between <%@ include ...> and <jsp:include>
difference between <%@ include ...> and   What is the difference between <%@ include ...> (directive include) and <jsp:include>
What is the difference between JSF, Servlet and JSP?
What is the difference between JSF, Servlet and JSP?  What is the difference between JSF, Servlet and JSP
Difference Between Servlet and JSP
Difference Between Servlet and JSP In this section we will describe the Servlet and JSP. We will compare the both technologies. We will discuss the differences between Servlet and JSP. Servlet Servlet is a Java class that is usually
calculate difference between two time in jsp
calculate difference between two time in jsp  How to calculate difference between two dates
SendRedirect()
SendRedirect()  What is the difference between sendRedirect() and forward()?   Response.sendRedirect (): This function is used, when we... resource (servlet, JSP file, or HTML file) on the server. Forward is done at server
Difference between class,name,id attributes in each JSP tag
Difference between class,name,id attributes in each JSP tag  Can i know the difference between class,name,id attributes in each JSP tags.................. These 3 are only used for reference ..... And what are the differernces
Struts ForwardAction vs Forward tag in jsp - Struts
Struts ForwardAction vs Forward tag in jsp  difference between struts ForwardAction class and Forward tag in jsp
What is the difference between JSP expression language and scriptlets? - JSP-Servlet
What is the difference between JSP expression language and scriptlets?  Hi, I just want to ask what is the difference between JSP Expression Langauge and JSP scriptlets? Pls help me.   Hi friend
Difference between DispatchAction and LookupDispatchAction
Difference between DispatchAction and LookupDispatchAction  What is the Difference between DispatchAction and LookupDispatchAction
difference between SessionState and ViewState
difference between SessionState and ViewState  What is the difference between SessionState and ViewState
difference between ForwardAction and IncludeAction
difference between ForwardAction and IncludeAction  What is the difference between ForwardAction and IncludeAction
Difference between struts and JSF
Difference between struts and JSF  What is the difference between struts and JSF
difference between == and === operators?
difference between == and === operators?  Is (====) operator available in java or not? difference between
what is difference between jdk1.5 and jdk1.6 - JSP-Interview Questions
what is difference between jdk1.5 and jdk1.6  what is difference between the jdk1.5 and jdk1.6 in java  Hi Friend, 1)Java 1.6 runs faster than Java 1.5. 2)Java 1.6 makes programming easier by implementing various
JSP Forward action
JSP Forward action  Jsp forward action tag examples
difference between varchar & varchar2?
difference between varchar & varchar2?  What is the difference between varchar & varchar2
Difference between 3d and 4d
Difference between 3d and 4d  what is the difference between 3d and 4d
What is the difference between the >> and >>> operators?
What is the difference between the >> and >>> operators?   hi, What is the difference between the >> and >>> operators? Thanks
Difference between GET and POST
Difference between GET and POST   Difference between GET and POST ?   The difference between a GET and a POST is the way data... this: http://www.roseindia.net/jsp?para1=paraValueADS_TO_REPLACE_1 With a POST
jsp:forward - JSP-Servlet
jsp:forward  Hi, I want check one condition if it is true the only I have forward it io jsp. My code is like this but it is not working please help...=formobject.formbeanvarable.value;(like /jsp/jspname.jsp) jsp name is captured from DB I
Difference between Mysql and SQL
Difference between Mysql and SQL  hello, What is the difference between Mysql and SQL??   hii,ADS_TO_REPLACE_1 SQL is structural quary language but mysql is database package
Difference between Timer and Thread?
Difference between Timer and Thread?  Can anyone tell me about the difference between Timer and Thread, Why we need to have Timer in case we have Thread implimentation startegy in Java
jsp:forward tag ussage
jsp:forward tag ussage  can you give me example of how to use jsp:forward tag... i intend to call action class   Hi Friend, Please visit the following links: http://www.roseindia.net/jsp/jsp-forward-request.shtml
what is the difference between extends and implements
what is the difference between extends and implements  difference between extends and implements
what is the difference between extends and implements
what is the difference between extends and implements  difference between extends and implements
jsp forward action tag
jsp forward action tag  Defined jsp forward action tag ?   ... application context as the forwarding JSP file. Syntax of forward action Tag:ADS_TO_REPLACE_1 <jsp:forward page="{relativeURL | <%= expression %>}" />
Difference between SCJP Exams
Difference between SCJP Exams  What is the differences between SCJP 5 (310 - 055) exam and SCJP 6 (310 - 065) exam??? Thank You In Adv
difference between lock and synchronization
difference between lock and synchronization  Hi, I am new in java please anyone tell me difference between lock and synchronization in java. its urgent. Thank in advance   Please visit the following link: Lock
Difference between request.getRequestDispatcher() and context.getRequestDispatcher()
Difference between request.getRequestDispatcher() and context.getRequestDispatcher()  What is the difference in using request.getRequestDispatcher() and context.getRequestDispatcher()?   request.getRequestDispatcher
Difference between ServletContext and ServletConfig
Difference between ServletContext and ServletConfig   What is the difference between ServletContext and ServletConfig?   ServletContext :Defines a set of methods that a servlet uses to communicate with its servlet
Difference between translate and replace
Difference between translate and replace   hiii, What is the difference between translate and replace?   hello,ADS_TO_REPLACE_1 Replace replace every instence of character with character sting by the given charator
jsp forward not functioning
jsp forward not functioning  If the form in AddStudent.jsp...". Is it because of that, the jsp:forward is not forwarding... the student in the database (works OK) } %>}else{%> <jsp
What is the difference between $message and $$message?
What is the difference between $message and $$message?  What is the difference between $message and $$message
What is the difference between PHP4 and PHP5?
What is the difference between PHP4 and PHP5?  What is the difference between PHP4 and PHP5
What is difference between a PROCEDURE & FUNCTION ?
What is difference between a PROCEDURE & FUNCTION ?  What is difference between a PROCEDURE & FUNCTION
Difference between XML and HTML - XML
Difference between XML and HTML  What is the basic Difference between XML and HTML
what is the Difference between weblogic and jboss?
what is the Difference between weblogic and jboss?  what is the Difference between weblogic and jboss
what is the difference between pop and oop
what is the difference between pop and oop  what is the difference between pop and oop
difference between hashcode,reference in java
difference between hashcode,reference in java  difference between hashcode,reference in java
What is the difference between hibernate and spring
What is the difference between hibernate and spring  Hi, What is the difference between hibernate and spring. Thanks
jsp:forward tag usage and stntax
jsp:forward tag usage and stntax  jsp:forward tag usage and syntax with an example
Difference between http and https
Difference between http and https  Difference b/w HTTP and HTTPS please provide answer in tabular form.   Hi Friend, Differences: 1)HTTP is hyper text transfer protocol which is responsible for transmitting
What is the difference between a constructor and a method?
What is the difference between a constructor and a method?  Hi, What is the difference between a constructor and a method?   Hi, I have found a good link of Java program related to difference between constructor
Difference between error and exception ????????
Difference between error and exception ?  Can we handle a error in java if yes than give an code of an example? Difference between error and exception handling.......   Exceptions are things you can create/throw
difference between applet and swings
difference between applet and swings  what are the major difference between swing and applets   Hello Friend, Differences:ADS_TO_REPLACE_1..._TO_REPLACE_3 Thanks   Hi Friend, Difference between Swing and Applet:ADS
Difference between jsonstring and json object
Difference between jsonstring and json object  Is There any difference between JsonString and jsonobjectA? if there is any differece could any one explain with example. Thanks venkatesh
how to use sendRedirect in doGet method in jsp?
how to use sendRedirect in doGet method in jsp?  i am getting problem in jsp that when we are directly writing address to a jsp page in addressbar the jsp page should redirect it to the html page.   can any one tell me

Ads