Thank you for your help, but I already know how to implement dynamic results
and how to use parameters in my results as well. And this is also not the
point. I wanna make a "forward" rather than a "redirect" to the same page.
But it doesn't work. I have a search-form on different pages. If validation
fails on a form property, the request should be forwarded to the same page
with the field error messages displayed. So redirect to the same page is not
the choise. You also have to know, that I use Tiles for my webapp.

In my struts.xml I've defined the following:

<action name="welcome" class="com.foo.BaseAction">
   <result type="tiles">welcomePage</result>
</action>

<action name="search" class="com.foo.SearchAction">
   <result type="redirect-action">searchResult</result>
   <result name="input" type="dispatcher">${referer}</result>
</action>

<action name="searchResult" class="com.foo.SearchResultAction">
   <result type="tiles">searchResultPage</result>
</action>

The SearchAction looks like class:

public class SearchAction extends ActionSupport implements Prepareable {

private String referer;

@Override
public void prepare() throws Exception {
   referer = request.getHeader( "Referer" );
   if (referer==null)
      referer = request.getContextPath();
}

public String getReferer() {
   return referer;
}

public String execute() throws Exception
{
    // do some searching
   return SUCCESS;
}


}


The getter-method for the referer property returns something like
"http://localhost:9001/welcome.action";, cos the search-form is included in
my welcome-page. I've got the feeling, that Tomcat's ApplicationDispatcher
makes some request string modifications in accordance to the servlet context
path.
The location after creating the dispatcher is
"//http:/localhost:9001/welcome.action". An obviously complete useless URI.



newton.dave wrote:
> 
> You may be able to use the existing dynamic result configuration to
> implement this; see these two links:
> 
> http://cwiki.apache.org/WW/result-configuration.html
> http://cwiki.apache.org/WW/parameters-in-configuration-results.html
> 
> Dave
> 
> --- On Sun, 12/14/08, Dirk Forchel wrote:
> 7:59 AM
>> Has somebody any idea regarding the problem mentioned below.
>> Every hint is appreciated.
>> 
>> 
>> Dirk Forchel wrote:
>> > 
>> > I need your help. I wanna use the DispatcherResult
>> (dispatcher) not as a
>> > forward to a JSP (jsp/pages/test.jsp), but rather to
>> forwarding to another
>> > action request e.g. /test.action?code=1. Apparently
>> there is no need for
>> > doing that until you define something like the
>> following in your
>> > struts.xml
>> > 
>> > <action name="test"
>> class="com.foo.TestAction">
>> >    <result
>> type="dispatcher">jsp/pages/test.jsp</result>
>> > </action>
>> > 
>> > I have written a "Request-History" where all
>> HTTP-Requests are stored on a
>> > stack, e.g. requests like
>> "/test.action?code=1" or
>> "/welcome.action" and
>> > so on. If I wanna pull these requests from the stack
>> and make a forward to
>> > these action forwards (in Struts 1 I have used the
>> ActionForward- or
>> > ActionRedirect class for doing this). So how could I
>> forward to actions
>> > like this in Struts2? Where did I miss something?
>> > I also implemented my own Result type (HistoryResult
>> implements Result)
>> > for pulling the stored HTTP-Requests from the
>> history-stack and try to
>> > forward and/or redirect to these URLs, but it
>> doesn't work either. I can't
>> > foward to something like /test.action but I can
>> redirect to another
>> > action. Where did I miss something. Here is the peace
>> of code. 
>> > 
>> > if (redirect) 
>> > { 
>> >    sendRedirect(response, location); 
>> > } 
>> > else 
>> > { 
>> >    RequestDispatcher dispatcher =
>> request.getRequestDispatcher(location); 
>> >    // if the view doesn't exist, let's do a
>> 404 
>> >    if (dispatcher == null) { 
>> >       response.sendError(404, "result '"
>> + location + "' not found"); 
>> >       return; 
>> >    } 
>> >    // If we're included, then include the view 
>> >    // Otherwise do forward 
>> >    // This allow the page to, for example, set content
>> type 
>> >    if (!response.isCommitted() &&
>> >
>> (request.getAttribute("javax.servlet.include.servlet_path")
>> == null)) { 
>> >      
>> request.setAttribute("struts.view_uri", location);
>> 
>> >      
>> request.setAttribute("struts.request_uri",
>> request.getRequestURI()); 
>> >       dispatcher.forward(request, response); 
>> >    } else { 
>> >       dispatcher.include(request, response); 
>> >    } 
>> > } 
>> > 
>> > 
>> > Here the Status after forward to this action:
>> > 
>> > HTTP Status 404 - //test.action
>> > 
>> > type Status report
>> > 
>> > message //test.action
>> > 
>> > description The requested resource (//test.action) is
>> not available.
>> > 
>> > 
>> > Even if I remove the first occurence of '/'
>> and the location is
>> > "test.action" rather than
>> "/test.action", I got the same HTTP status
>> > result. What's wrong with it?
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/-S2--ServletDispatcherResult-%28dispatcher%29-and-forwarding-to-Actions-tp20950033p21000088.html
>> Sent from the Struts - User mailing list archive at
>> Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
>> For additional commands, e-mail:
>> user-h...@struts.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/-S2--ServletDispatcherResult-%28dispatcher%29-and-forwarding-to-Actions-tp20950033p21009668.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to