File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Getting the URL from the request using Struts? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Application Frameworks » Struts
Reply Bookmark "Getting the URL from the request using Struts?" Watch "Getting the URL from the request using Struts?" New topic
Author

Getting the URL from the request using Struts?

Andr� Branco
Greenhorn

Joined: Sep 28, 2004
Posts: 7
Hi,

I am using Struts and my urls look like this

http://server/action.do

All my actions extend a base action and I need to know what action is being called, e.g action.do. None of the request methods seem to return this part of the URL and I do not know whether i can determine this within struts.

I already tryed for example with the given the url

http://server/loadAction.do?a=b

getQueryString() = a=b
getRequestURI() = /path/to/page.jsp
getContextPath() = /path/to/page.jsp

page.jsp is the view that the struts framworks forwards to. What I am interested in is getting the loadAction.do part

Thank you very much!

Best regards,
Andr� Branco
Sree Jag
Ranch Hand

Joined: Oct 14, 2003
Posts: 77
hi Andre,

try request.getServletPath();

Seshu


Sree Jag<br />SCJP 1.4
Sheldon Fernandes
Ranch Hand

Joined: Aug 18, 2004
Posts: 157
Do you need to know this from the base action's execute method? If so, then you can use the getPath method of the ActionMapping object.

Sheldon Fernandes
Andr� Branco
Greenhorn

Joined: Sep 28, 2004
Posts: 7
I am not in the actions�s execute method. If I were it would work. And the getServletPath() too.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4695

Where ARE you?


A good workman is known by his tools.
Andr� Branco
Greenhorn

Joined: Sep 28, 2004
Posts: 7
I am in custom tag that I create, used in JSP.
 
 
subject: Getting the URL from the request using Struts?
 
Threads others viewed
JSF: calling a page without calling a page
Adding javascript to struts 2 jsp
What is the term? A redirect at the server level...
j_security_check and apache httpd ProxyPass
Nice URLs
developer file tools