jQuery in Action, 3rd edition
The moose likes Servlets and the fly likes Servlet needs to pick up page name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet needs to pick up page name" Watch "Servlet needs to pick up page name" New topic

Servlet needs to pick up page name

Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

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.

GenRocket - Experts at Building Test Data
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

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 ]

[Asking smart questions] [About Bear] [Books by 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.
I agree. Here's the link: http://aspose.com/file-tools
subject: Servlet needs to pick up page name
It's not a secret anymore!