Solved

forward

Posted on 2006-07-14
5
312 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mockito Method call failing. 3 188
Session migration 1 102
AlarmClock Challenge 35 145
How to find missing packages when using Netbeans IDE 8.1 ? 19 46
Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
In 2017, ransomware will become so virulent and widespread that if you aren’t a victim yourself, you will know someone who is.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now