• Post Reply Bookmark Topic Watch Topic
  • New Topic

knowing invoking JSP page name

 
Sa'eed Waseem
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have abc.jsp being invoked or called by, say, a link in xyz.jsp.

how can abc.jsp know the invoker...can abc.jsp know it was inovked by a servlet, JSP, or any other resource?

Is there a method in the request object or any of the other JSP implicit objects that enable us to know who the invoker is?

thanks,
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the getUserPrincipal(), getRequestURL() and getRemoteUser() methods of the javax.servlet.http.HttpServletRequest class.
[ December 01, 2008: Message edited by: James Clark ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RED FLAG ALERT

Why? Such question are indications of a design flaw 99% of the time. If you plan to switch operations in the page based upon where you came from, don't! Such implicit conditions are a bug waiting to happen. Rathet, used a scoped variable or parameter to explicitly switch the behavior.
 
Sa'eed Waseem
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, thanks for the replies.

I am building dynamic links by using a generic custom tag.

so when that custom tag is called in, say, abc.jsp, i want it to build dynamic links like this: abc.jsp?param1=val1¶m2=val2


the dynamic part is the name of the JSP page where i will be forwarding the request.

the custom tag maybe called inside many other pages..so i need to know the name of the pages where this tag is called to build the dynamic link based on that page name..

If the way i asked indicates design flaws...what would be the best way to know the name of the jsp page so that i can include it in the link?

thanks,
 
Sa'eed Waseem
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks James, javax.servlet.http.HttpServletRequest was a helper.

i only had to cast my ServletRequest object to an HttpServletRequest to get a whole bunch of methods that I didn't know of...

good hint..

thanks,
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not really what you asked. Do you need to know the name of the "current" page, or the previous (invoking) page? Sounds like the former.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!