Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forward to different context

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was not aware of this.
We can 'forward' request to the resources present in other context/application...
Will it work even if both applications are not on same server???


You can not use a jsp:forward between two different servler contexts. You can use a RequestDispatcher forward between two different contexts (at least on tomcat)

1: enable cross context capability in the context config file for both contextts.
2: get a reference to the other context using ServletContext.getContext("name")
3: get the RequestDispatcher for the other context using the context object from step 2
4: do the forward

All of this logic could be coded into a custom tag.


From: http://forum.java.sun.com/thread.jspa?threadID=593250&messageID=3109439
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Will it work even if both applications are not on same server???

No, you'll have to redirect.
 
Vikrant Pandit
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ankur,

Just be aware that you verify that this works in your production environment which usually have highly restrictive security settings. You need to watch if your application shares the app server with other applications

Just a thought !
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vivek Pandey:
Hi Ankur,

Just be aware that you verify that this works in your production environment which usually have highly restrictive security settings. You need to watch if your application shares the app server with other applications

Just a thought !


Thanks Satou and Vivek.
I was also thinking that this can be a feature of tomcat or any other web/application server but we shouldn't consider this a possiblility, I mean Sun didn't mean to provide this... just thinking, not sure.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic