Author
Getting the URL from the request using Struts?
Andr� Branco
Greenhorn
Joined: Sep 28, 2004
Posts: 7
posted Sep 28, 2004 11:49:00
0
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
posted Sep 29, 2004 06:33:00
0
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
posted Oct 01, 2004 11:52:00
0
I am in custom tag that I create, used in JSP .
subject: Getting the URL from the request using Struts?