struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk Forchel <>
Subject Re: [S2] ServletDispatcherResult (dispatcher) and forwarding to Actions
Date Tue, 16 Dec 2008 08:17:59 GMT

okay, I could strip off the context path from my "referer", but using a
relative URL like "/welcome.action" or "/demostore/welcome.action" doesn't
work either. Only something like "/jsp/pages/welcome.jsp" or similiar (a
relative URL with a JSP resource) works for me. But I wanna use Tiles, so
this result doesn't help me and I need a forward to a "Action" rather than a
JSP. If validation fails on my search action, the field error should be
displayed on the same page the input error occured. The seach form is used
on almost every page. 
This problem drives me almost insane!!! You can test it by your own.
Here is my Test-Configuration (without Tiles) and almost the complete code:


   <package name="demostore" extends="struts-default">
      <default-interceptor-ref name="paramsPrepareParamsStack"/>
      <default-action-ref name="welcome"/>
	<result name="input">${referer}</result>			
      <action name="search" class="">
      <!-- Using Wildcard mapping for all actions without action classes -->
      <action name="*" class="">

public class BaseAction extends ActionSupport implements
ServletRequestAware, Preparable
   private String referer;
   protected HttpServletRequest request;
   public void setServletRequest(HttpServletRequest request)
      this.request = request;

   public void prepare() throws Exception {
      referer = request.getHeader( "Referer" );
      if (referer==null)
         referer = request.getContextPath();
   public String getReferer() {
      // THIS WORKS
      // return "/jsp/pages/welcome.jsp";
      // return "/welcome.action";
      return referer;

public class ForwardAction extends BaseAction 
   public String execute() throws Exception 
      return executeInternal();

   protected void addToHistory(HttpServletRequest request)
      // Request History
      // History.addEntry(request);
   protected String executeInternal() throws Exception 
      return SUCCESS;

public class SearchAction extends BaseAction
   private String searchString;
   public String execute() throws Exception 
      return SUCCESS;

   public void setSearchString(String searchString) {
      this.searchString = searchString;

   public String getSearchString() {
      return searchString;


<%@ page language="java" contentType="text/html; charset=UTF-8"
	import="com.exedio.demostore.web.Constants" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF8">
      <meta http-equiv="Content-Style-Type" content="text/css;
      <title><s:text name="welcome.headline"/></title>		
      <link rel="stylesheet" type="text/css" href="css/default.css">	
      <h1><s:text name="welcome.headline"/></h1>
      <s:include value="" />

<%@ page language="java" contentType="text/html; charset=UTF-8"
	import="com.exedio.demostore.web.Constants" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<s:form action="search">
      <label for="searchString"><s:text name="search.term"/></label>
      <s:textfield name="searchString" />
      <s:submit key="search.submit" />


<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator
1.0.2//EN" "">

    <field name="searchString">
        <field-validator type="requiredstring">
            <message key="error.searchstring.required"/>

Nils-Helge Garli wrote:
>> 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.
> According to the servlet specification, the path to the request
> dispatcher must be relative to the root of the servlet context,
> starting with the '/' character, so an absolute url won't work.
> Nils-H
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message