Tim Sheridan wrote:
 I think I have a good understanding of how to incorporate STRUTS in my JSPs. The problem I'm having is with the Action Servlet Mapping. My goal is to keep my JSPs small in size so I have one (session) bean that is populated from form properties from eash JSP (a total of 5 in all). My web.xml has the Servlet Mapping defined as:

  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>/webapp/*.do</url-pattern>
  </servlet-mapping>
 

Well, one problem you are going to have is that this is not a valid URL pattern for a servlet mapping.  If you want to use extension mapping (as the example app does), you will want to use "*.do" instead of "/webapp/*.do".
 
All my form action attributes have ".do" extension and the same form bean name. The action.xml is configured as:

<action-mappings>

  <!-- Global Forward Declarations -->
  <forward name="introduction"        path="/SpcIntroduction.jsp"/>

  <!-- Process test -->
  <action    path="/introduction"
      actionClass="request.spc.SpcRequestAction"
    formAttribute="spcRequest"
        formClass="request.spc.SpcRequestForm"
        inputForm="/SpcIntroduction.jsp">
    <forward name="next"    path="/SpcInformation.jsp"/>
  </action>
  <action    path="/information"
      actionClass="request.spc.SpcRequestAction"
    formAttribute="spcRequest"
        formClass="request.spc.SpcRequestForm"
        inputForm="/SpcInformation.jsp">
    <forward name="next"    path="/SpcSchedule.jsp"/>
  </action>
  <action    path="/schedule"
      actionClass="request.spc.SpcRequestAction"
    formAttribute="spcRequest"
        formClass="request.spc.SpcRequestForm"
        inputForm="/SpcSchedule.jsp">
    <forward name="next"    path="/SpcMessage.jsp"/>
  </action>
  <action    path="/message"
      actionClass="request.spc.SpcRequestAction"
    formAttribute="spcRequest"
        formClass="request.spc.SpcRequestForm"
        inputForm="/SpcMessage.jsp">
    <forward name="next"    path="/SpcConfirmation.jsp"/>
  </action>
  <action    path="/confirmation"
      actionClass="request.spc.SpcRequestAction"
    formAttribute="spcRequest"
        inputForm="/SpcConfirmation.jsp"
        formClass="request.spc.SpcRequestForm">
    <!--forward name="next"    path="/SpcConfirmation.jsp"/-->
  </action>

</action-mappings>

When I run with this configuration locally using Tomcat 3.2.1, everything seems to work okay when going to the "next" page (yet the browser always shows the ".do" name of the form). But when I transfer the pages and this configuration to my Servlet hosting website, the server can never find the "next" page and can't resolve finding "introduction.do".

I am missing something here. Please give me some expert advice on how to make this work properly both locally and live, and how to make the ".jsp" appear in the browser URL area for all my pages. TIA

Besides the invalid servlet mapping, if you are just getting started with Struts I would strongly encourage you to use one of the recent nightly builds, rather than the Struts 0.5 release.  They are quite solid, and there are a *substantial* number of incompatible API changes.  A final release of 1.0 will happen fairly soon, and you will save yourself a major conversion headache if you make the switch before you start coding, rather than after.

Craig McClanahan
 

Reply via email to