Solved

forward

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
netstat -a in AIX unix 8 48
method inner class 6 83
maven j2ee examles 2 60
struts hibernate integration example 28 143
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This article shows the method of using the Resultant Set of Policy Tool to locate Group Policy that applies a particular setting.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 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