GeeCON Prague 2014*
The moose likes Struts and the fly likes Problem in running Struts tutorial example by Isabelle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem in running Struts tutorial example by Isabelle " Watch "Problem in running Struts tutorial example by Isabelle " New topic
Author

Problem in running Struts tutorial example by Isabelle

C Wong
Greenhorn

Joined: May 28, 2002
Posts: 18
I am new to Struts. I followed the Jakarta Struts - A beginner's tutorial by Isabelle but have a problem in running the first example.
I should see a directory listing with files by entering http://localhost:8080/registeruser/
The error message:
HTTP Status 404 - /registeruser/
type Status report
message /registeruser/
description The requested resource (/registeruser/) is not available.
My Tomcat Apache Tomcat/4.1.18 is working fine. I could use it to run other examples.
I am not using Eclipse but I have created:
the index.jsp in webapps\registeruser
web.xml in webapps\registeruser\WEB-INF.
The struts.jar is copied to \webapps\registeruser\WEB-INF\lib.
I would appreciate if someone could help me to solve this problem in order to continue with the tutorial.
Thank you in advance.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi,
it looks like you didn't map the StrutsController Servlet to /registeruser/.
Normaly you can do it two ways:
- Map this Servlet to a certain path e.g. /do/* now every request to this URL is handled by the servlet
- or map an ending to the servlet /*.do
But anyway one of these configurations has to be done.
Then it should work
If it is still not working, please post your web.xml and struts-config.xml
Olli
C Wong
Greenhorn

Joined: May 28, 2002
Posts: 18
Hi Olli, according to the tutorial (at section: Learning by example: your first Struts application), there is no mention of struts-config.xml yet. However, the web.xml has a reference to it. That could be the cause of problem that Tomcat could not create a web application called "registeruser". I still have a same problem after creating the struts-config.xml.
---- web.xml -------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<!-- Action Servlet Configuration -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>

<!-- Resources bundle base class -->
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>

<!-- Context-relative path to the XML resource containing Struts configuration information -->
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>

<!-- The debugging detail level for this servlet, which controls how much information is logged. -->
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<!-- Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<!-- The Welcome File List -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- Application Tag Library Descriptor -->
<taglib>
<taglib-uri>/WEB-INF/app.tld</taglib-uri>
<taglib-location>/WEB-INF/app.tld</taglib-location>
</taglib>
<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
</web-app>

------ struts-config.xml --------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
<struts-config>
<form-beans>
<!-- Logon form bean -->
<form-bean name="loginForm"
type="LoginForm"/>
</form-beans>

<global-forwards>
<forward name="mainmenu" path="/mainmenu.jsp" />
</global-forwards>

<action-mappings>
<!-- Process a user logon -->
<action path="/login"
type="LoginAction"
name="loginForm"
scope="session"
input="/index.jsp">
</action>

</action-mappings>
</struts-config>
 
GeeCON Prague 2014
 
subject: Problem in running Struts tutorial example by Isabelle