Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getRequestDispatcher()  RSS feed

 
siddharth das
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all,
i want to know the difference between

please give me an example of each one.
Thank You.
 
siddharth das
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to use getContext() to obtain a RequestDispatcher for resources in foreign contexts.please give me an example with code.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html

getContext(java.lang.String uripath)
Returns a ServletContext object that corresponds to a specified URL on the server.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keep in mind, the servlet spec does not go into a lot of detail when it comes to explaining how cross context communication should be implemented so you can expect inconsistent behavior, at best, among various containers.

I know Tomcat, by default, does not allow cross-context communication.
To enable it, you have to set the crossContext attribute to "true" in your context entry.
 
yugant shah
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

The request.getRequestDispatcher("String url");
Here the url is relative to the particular request i.e the path is relative to the current resource.
Whereas, when we say,
getServletContext().getRequestDispatcher("String url"),
the url is relative path to the web-context.
So this url starts with a "/". in case of text().getRequestDispatcher("String url").

Thanks,
Yugant Shah.
 
yugant shah
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Sorry ,
the last line is >>

So this url starts with a "/". in case of getServletContext()().getRequestDispatcher("String url").
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by yugant shah:
Hello,
Sorry ,
the last line is >>


You can edit a post to fix errors by clicking the button.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!