Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

struts1.1 and tomcat 5.5.27

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am trying to follow this tutorial: http://www.coreservlets.com/Apache-Struts-Tutorial/Struts-Actions.html (the one result mapping) but when I click "sign me up" in register1.jsp I get "The requested resource (/struts-test/actions/register1.do) is not available." My directory layout:

TOMCAT_HOME/webapps/struts-test contains 3 directories:
actions
forms
WEB-INF

actions contains RegisterAction1.java
forms contains register1.jsp
WEB-INF contains
1. classes/coreservlets/RegisterAction1.class
2. results/result1.jsp
3. struts-config.xml.

 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without the configuration it's difficult to help.

Are there any error messages when you start up? Have you increased logging levels?
 
Marcus Halberstram
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The struts configuration file is:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC ... >
<struts-config>
<action-mappings>
<action path="/actions/register1.do"
type = "actions.RegisterAction1">
<forward name="success"
path="/WEB-INF/results/result1.jsp"/>
</action>
</action-mappings>
</struts-config>

The action path is exactly as it looks in the url when you click the sign me up button. The type of the action class is the location of the java source that is the action class. Thanks.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags.

I don't think you should be specifying the Struts extension in the S1 action mapping.

The action path is exactly as it looks in the url when you click the sign me up button.


I'm not sure what that means.
 
Marcus Halberstram
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I click the sign me up button it goes to the same url that I specified in the action path: /actions/register1.do. I got rid of the .do from the action path but it still gives me the same error. My struts config file is like this now:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC ... >
<struts-config>
<action-mappings>
<action path="/actions/register1"
type = "actions.RegisterAction1">
<forward name="success"
path="/WEB-INF/results/result1.jsp"/>
</action>
</action-mappings>
</struts-config>
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags.

The package the class lives in is different from the package name you're using in your config. You said the class file was in /WEB-INF/classes/coreservlets, but you're using a package of "actions" in the action mapping.

There's no class file in that package.
 
Marcus Halberstram
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From my knowledge, the action type is the fully qualified name of the action class. In this case, it would be RegisterAction1.java, which belongs to the package coreservlets. So the type should be coreservlets.RegisterAction1. Is the action type the location of the .class file or the fully qualified name of the action class? It looks like in this case it would be the same.
struts-test contains
actions
---->RegisterAction1.java:

WEB-INF
---->classes---->coreservlets---->RegisterAction1.class
---->results
---->struts-config.xml:

forms
---->result1.jsp

This application is called struts-test and is in the webapps directory of my tomcat 5.5.27 installation. After restarting struts-test in tomcat manager, I navigate to "http://localhost:portnumber/struts-test/forms/register1.jsp". I click on the sign me up button and see "The requested resource (/struts-test/actions/register1.do) is not available." Why don't I need the .do extension in struts-config.xml if I don't associate .do with an action path?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those two Struts config files aren't the same--the second (latest) one has the correct type in the action config, the first one didn't.

Why don't I need the .do extension in struts-config.xml if I don't associate .do with an action path?


What? You don't need the extension in the config file because Struts handles the extension.

Do you not have a web.xml that configures Struts?!
 
Marcus Halberstram
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The tutorial does not have a web.xml so I don't have one either, is that what is causing the problem? Thanks.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That'll be a pretty major issue, yes. Without it there's no way for Struts to know it should process any requests.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic