Discussions

Web tier: servlets, JSP, Web frameworks: Struts and loading the first page

  1. Struts and loading the first page (9 messages)

    Hello to all!!

    I am rather new to struts and for the life of me cannot get it working on an initial request to the application. If I supply the following url:

    http://mydomain/nyssis/home.do

    I get the expected resulting page. If I supply just:

    http://mydomain/nyssis/

    I get the standard directory listing that appears when a requested welcome page cannot be found. Is there a parameter I need to set somewhere that will force the call to home.do? Help!!!

    Threaded Messages (9)

  2. Struts and loading the first page[ Go to top ]

    I forgot to mention that I worked around this by adding the following line as the only content of index.jsp:

    <% response.sendRedirect("home.do"); %>

    which takes care of the issue, but I don't believe that this is the correct resolution.

    Thanks again for any assistance provided!!
  3. Struts and loading the first page[ Go to top ]

    Are you sure you have map the url "*.do" to the ActionServlet in the web.xml? i.e.

      <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
        <init-param>
          <param-name>config</param-name>
          <param-value>/WEB-INF/struts-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
      </servlet>

      <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
      </servlet-mapping>
  4. Struts and loading the first page[ Go to top ]

    yes,you are right? can you understatd what i mean,if no,please email:tian_zl@263.net
  5. Struts and loading the first page[ Go to top ]

    sorry.yes,you are right! can you understatd what i mean,if no,please email:tian_zl@263.net
  6. Struts and loading the first page[ Go to top ]

    You can also set the unknown attribute of the first action to true. The Struts servlet will then redirect to this action automatically if it sees a URL it can't map.
  7. Struts and loading the first page[ Go to top ]

    This sounds like a better solution than the redirect. Where would I set this attribute?
  8. Struts and loading the first page[ Go to top ]

    you can wirte
    struts-config like this
    <global-forwards>
    <forward name ="welcome" path="XXXXX.do">
    <global-forwrds>

    welcome.jsp like this
    <logic forward name='welcome'>

    web.xml
    <welcome-file-list>
    <welcome-file>welcom.jsp<welcom-file>
    <welcome-file-list>
  9. Struts and loading the first page[ Go to top ]

    some containers will not serve that welcome file unless a physical file exists there... create an index.html and then rename it to home.do-- the container should still server your struts action, not that file.
  10. Thank god somebody said that. I've been going nuts trying to figure out why Tomcat won't serve up my index action when it has been set in the welcome-file-list. Created an empty file in the right place, and it worked. Much thanks.