Meaningless Drivel is fun!*
The moose likes Struts and the fly likes Redirect url with in the action class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Redirect url with in the action class" Watch "Redirect url with in the action class" New topic
Author

Redirect url with in the action class

meMalik Ahmed
Greenhorn

Joined: Sep 29, 2010
Posts: 3
Dear friend i am new to struts2 me want to redirect my action with in the action class without using Struts.XML
let suppose my requested URL is
http://localhost:8080/my/myidex.jsp
to
http://localhost:8080/my/jsp/myidex.jsp
internally from action class without changing the URL in the browser. Like filter in Spring
sorry if me cant explain you clearly but if any one know please post some material
Thanks
Srinivas Kollaparthi
Greenhorn

Joined: Jan 19, 2008
Posts: 11
Lets us see if my understanding is correct.
your config xml looks like

Usually in your action class, you will return ActionForward object by calling mapping.findForward("success") to go to "/myindex.jsp"
If you want to redirect to some other page without specifying in config xml,
you will get actionforward object by instantiating it with your new path and return it.
meMalik Ahmed
Greenhorn

Joined: Sep 29, 2010
Posts: 3
thanks brother for your reply..
but my question is little bit different..
actually me want to internally redirect my request to any action without feel changing my URL to user.
Let me explain more clearly
my requested URL is
http://localhost:8080/my/myindex.action
me call this action then request will go in the myindex.action class
from that class me want to internally redirect to some other action class e.g
http://localhost:8080/my/home.action and do some process and takes value from that then com back to
http://localhost:8080/my/myindex.action...
means internally redirect
hope me define some more clear picture...
sorry if there is any confusion


Raza Mohd
Ranch Hand

Joined: Jan 20, 2010
Posts: 247

You can use interceptors to perform task that you want .
In interceptor you can call any Action .


Good luck!!
A small leak can sink a Gigantic ship.>
meMalik Ahmed
Greenhorn

Joined: Sep 29, 2010
Posts: 3
dear brother you suggested me to use interceptor.
now the problem i am facing is that me can only call interceptor before or after result..
how we can manually call a interceptor a specific point in the action..
let suppose me in the action class
public String execute()
{

1...........
2...........
3...........
4.(call interceptor)
5..........


}
in the method after execute me want to call interceptor and pass some parameters to interceptor...
and in the interceptor on behalf of the parameter i can do further processing then i can send any data(List) back to action..
thank in advance
and sorry if any confusion occur

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Redirect url with in the action class
 
Similar Threads
URL - getting appended
Having a hard time getting my servlet to be available
how to execute actions without typing "action" at last of URL?
Problem with the Contextpath in the url
Use welcome-file-list to run struts action?