| Author |
Servlet needs to pick up page name
|
Dale DeMott
Ranch Hand
Joined: Nov 02, 2000
Posts: 514
|
|
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?
|
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
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
Joined: Jan 10, 2002
Posts: 56554
|
|
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 ]
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Ken Robinson
Ranch Hand
Joined: Dec 23, 2003
Posts: 101
|
|
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.
|
 |
 |
|
|
subject: Servlet needs to pick up page name
|
|
|