Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem running a struts 1.1 tutorial

Status
Not open for further replies.

AnthonyGeorge

Technical User
Jun 3, 2004
46
0
0
GB
am attempting the Struts tutorial for struts 1.1

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
 
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"
"
<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
 
You name your struts config file as servletconfig.xml, but in web.xml, you refer it as /WEB-INF/struts-config.xml

you better have the config file rename to struts-config.xml and put it in the /WEB-INF directory, where the web.xml file is located.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top