473,516 Members | 2,865 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

jsp:forward and RequestDispatcher.forward

dmjpro
2,476 Top Contributor
Could anyone tell me what is difference between jsp:forward and RequestDispatcher.forward?

These two codes behave differently ...

Expand|Select|Wrap|Line Numbers
  1. <jsp:forward page="page_ref"/>
  2.  
and

Expand|Select|Wrap|Line Numbers
  1. request.getRequestDispatcher("page_ref").forward(request,response);
  2.  
In first case ...... after getting forwarded the next statements are not getting executed.

But in second case ..in spite of getting forwarded the next statements are getting executed .....
Wy?
Nov 13 '08 #1
5 7659
r035198x
13,262 MVP
The second case is called from a servlet which is a normal Java class so the normal program flow rules of Java apply.
Nov 13 '08 #2
dmjpro
2,476 Top Contributor
The second case is called from a servlet which is a normal Java class so the normal program flow rules of Java apply.
No No ...in both case i am doing in JSP.
Nov 13 '08 #3
r035198x
13,262 MVP
It doesn't matter, it's still a strict Java context and normal Java rules apply.

P.S Why are you double posting this?
Nov 13 '08 #4
itsraghz
127 New Member
No, it should NOT run any statements after you have forwarded to a resource.

Though the jsp:forward and RequestDispatcher.forward() may seem to be different in your perspective, to the container it matters the same. Obtaining a resource and forward the control/request to it. That's all.

It should/does NOT include the output generated in the resource from where the request is forwarded! Once the control is forwarded, the forwarded resource takes care from then on!
Nov 13 '08 #5
dmjpro
2,476 Top Contributor
It doesn't matter, it's still a strict Java context and normal Java rules apply.

P.S Why are you double posting this?
Sorry i didn't see that ... it was moved ...
By the way ..thanks for your reply ..
but ..the thing is ..JSP page ultimately converted into .... Java code then?
Nov 13 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
8562
by: K S Aldebaraan | last post by:
I'm trying to submit a form with an action of a servlet, and a view equal to the same jsp page. I'm not sure what I'm doing wrong, but keep getting a NullPointerException on the second line of code below: RequestDispatcher dispatcher = myConfig.getServletContext().getRequestDispatcher(view); dispatcher.forward(request, response); The...
1
3818
by: Sascha Pohlmann | last post by:
hello, I have the following problem: I would like to evacuate the logic from my jsp files in servlets. servlets provide database contents prepared in HTML tables, the jsp files are supposed to offer the graphic structure of the intranet application. how does the path detail have to look?
0
2396
by: NoSpamForMe | last post by:
I am currently a java programmer, with some knowledge of the C# language but very little knowledge about ASP.NET, and I am know wondering if someone can *translate* the java servlet code below to ASP.NET/C# ? Please note that I am not asking about the best possible way of doing the same thing with ASP.NET architecture with those "code...
0
2635
by: krishna81m | last post by:
Could some one please explain why the session is not being maintained when I am doing a forward in a servlet after setting a cookie. I am even unable to set session attributes or parameters and do a forward from a servlet to another servlet via a JSP page, the attributes seize to exist. I still do not understand the concept of session...
16
10202
by: naveenkongati | last post by:
hi, Please have a look at the following jsp page code , when this page gets loaded "null" is being printed. Please suggest me where i am doing wrong. Servlet code is also added for more details. Page: javatest.jsp <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01...
3
7082
by: sumanta123 | last post by:
Dear All, In the DoPost() i am calling the function sendTextMail(strFromUser, strToUsers, strCcUsers, strSubject, strMessageBody, strobjAttachments) in the Try catch block. Now the code compiles perfectly. My doubt is how i will write RequestDispatcher method in Dopost() if it is success then it will go to RequestDispatcher...
1
3073
by: sumanta123 | last post by:
Dear Sir, I am calling procedure in my servlet program.The procedure returns correct valule. For example If the Logid id wrong then errorType Returns E and errorDesc LOGIN ID IS NOT AVAILABLE. i am set this error message request.setAttribute("errorLogin", "Invalid Login ID") and forward to /help/NewPassword.jsp If the Date of Birth...
8
27012
by: webster5u | last post by:
I'm design MVC structure for current developing system. Initially, the jsp will post data to servlet class. After processing, servlet will use the requestDispatcher to return processed data back to jsp. RequestDispatcher dispatcher = request.getRequestDispatcher("/webapps/hrd/test.jsp"); dispatcher.forward(request,response); Now, the...
0
983
by: mosis | last post by:
I really need help , i am working on an application with netbeans and servlets. I have a form in which i give the id then select a table in which i will go and search the id to the oracle database. i am trying to send my objet to the jsp file from the servlet. -------------------------------------------- this is the way i did ...
0
7276
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4773
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3267
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1624
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
825
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.