Solved

forward

Posted on 2006-07-14
5
311 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
Comment Utility
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
Comment Utility
0
 
LVL 2

Expert Comment

by:pankilmpatel
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Run jasper report from servlet 1 206
Fisheye tool 2 101
parse example 13 85
eclipse luna javeEE perspecive missing 5 77
This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
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: …

772 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

10 Experts available now in Live!

Get 1:1 Help Now