Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

struts1.1 and tomcat 5.5.27

 
Marcus Halberstram
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic