Solved

forward

Posted on 2006-07-14
5
317 Views
Last Modified: 2008-01-09
Hi,
what's the difference between :

1)
getServletContext().getRequestDispatcher(urlErreur).forward(request,response);

2)
request.getRequestDispatcher(urlErreur).forward(request,response);


I'm new to JSP thank you.
0
Comment
Question by:matthew016
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 8

Assisted Solution

by:kaliyugkaarjun
kaliyugkaarjun earned 100 total points
ID: 17113296
Difference between
request.getRequestDispatcher("url").forward(request,response);

and

getServletConfig().getServletContext().getRequestDispatcher("url").forward(request,response);

One : you can pass relative URL address when using request.getRequestdispather, and absolute URL address when using ServletConfig.getRequestDispatcher.

Two: All request details are not passed when using ServletConfig.getRequestDispatcher. May be it is the query string parameters for the current page that does not reach the page where request is forwarded.

Also go thr this link for more info

http://forum.java.sun.com/thread.jspa?threadID=650087&messageID=3824146
0
 
LVL 8

Expert Comment

by:kaliyugkaarjun
ID: 17113299
0
 
LVL 2

Expert Comment

by:pankilmpatel
ID: 17119671
Hi,

request.getRequestDispatcher(path): In order to create it we need to give the relative path of the resource, context.getRequestDispatcher(path): In order to create it we need to give the absolute path of the resource.

Regards,
pankil Patel
0
 
LVL 9

Author Comment

by:matthew016
ID: 17120802
I use
getServletContext().getRequestDispatcher("index.jsp").forward(request,response);
so it's a relative path and it works well
0
 
LVL 2

Accepted Solution

by:
pankilmpatel earned 400 total points
ID: 17121030
hi,

REQUEST: relative paths that are relative to the path of the current request (not relative to the root of the ServletContext),
CONTEXT: relative to the root of the ServletContext and begin with a '/'.

you can refer following link for more understanding.
http://java.boot.by/wcd-guide/ch03s05.html

For reference..
http://www.techinterviews.com/?p=148
http://www.knowd.co.jp/tech/skeletons/repositry/j2ee/servlet/caseofdispatcher.html

Regards,
Pankil
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question