Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

forward

Posted on 2006-07-14
5
Medium Priority
?
319 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 400 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 1600 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

With the evolution of technology, we have finally reached a point where it is possible to have home automation features like having your thermostat turn up and door lock itself when you leave, as well as a complete home security system. This is a st…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

604 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