aspose file tools*
The moose likes Struts and the fly likes Problem running a struts 1.1 tutorial Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem running a struts 1.1 tutorial" Watch "Problem running a struts 1.1 tutorial" New topic
Author

Problem running a struts 1.1 tutorial

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 576
I am attempting the Struts tutorial for struts 1.1
http://www.coreservlets.com/Apache-Struts-Tutorial/Struts-Actions.html#Ex2-Step4.

When I try to run the first example I get the following error:

error description: The requested resource (/actions/register1.do) is not available.

The JSP has the following call
<FORM ACTION="../actions/register1.do" METHOD="POST">

This will call the following java class : coreservlets.RegisterAction1

which is mapped in the servletconfig.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC ... >
<struts-config>
<action-mappings>
<action path="/actions/register1"
type="coreservlets.RegisterAction1">
<forward name="success"
path="/WEB-INF/results/result1.jsp"/>
</action>
</action-mappings>
</struts-config>

There is no mention of using a web.xml file so far but I added it so that it could call the tag libries. Should there also me a mapping in the web.xml file I saw a extract from someone who had the same problem to add the following to my web.xml

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

This called the following error:

SEVERE: Parse Error at line 7 column 80: Attribute "types" must be declared for
element type "action".
org.xml.sax.SAXParseException: Attribute "types" must be declared for element t
pe "action".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(U
known Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndVali
ate(Unknown Source)

I know how to write servlets but not actions in the web.xml config file.

Thanks for any help.

Tony
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Here is a better tutorial for a beginner.


A good workman is known by his tools.
Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 576
Thanks Marc,

Will attempt this one, the other one seems too complex and is not very good at breaking down each segment.

Tony
Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 576
I have built the web.xml but am still getting that same error : The requested resource (/actions/register1.do) is not available.

web.xml is as follows:
<?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>
<display-name>Struts Example Application</display-name>

<!-- Action Servlet Configuration -->
<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>


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

<!-- Application Tag Library Descriptor -->
<taglib>
<taglib-uri>/tags/struts-bean</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-logic</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-nested</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/tags/struts-tiles</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>

</web-app>

If anyone ever solves this I would be glad to know what the problem was.

Tony
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

What does your struts-config.xml look like?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem running a struts 1.1 tutorial