• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet needs to pick up page name

 
Dale DeMott
Ranch Hand
Posts: 515
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought I posted this before but I couldn't find the text coupled with the header.

I need to pick up the JSP page name from the servlet so I can decide how to process this page. How might I get the jsp page name from the servlet engine. Is there a method or an attribute for this?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use request.getRequestURI(); which should return the page the request came from. You will have to substring out all the extra stuff in the string that comes with it. But that's not a big deal.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64180
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really think that this type of tight coupling is the best way to make run-time decisions?
[ July 22, 2004: Message edited by: Bear Bibeault ]
 
Ken Robinson
Ranch Hand
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want to do this? Are you writing one Servlet for the entire web app or are you rolling your own framework? What do you do when one JSP could have many different ways to process a request?

Do what is common J2EE/Web practice. Have the page submit to a URL that represents the processing you want. This way you can have multiple pages call the same URL for the same processing. Simply use the <servlet-mapping> tag in web.xml to bind the URL to a Servlet defined with a <servlet> tag and you're done. No writing your own code and thinking of goofy names to call your framework.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic