aspose file tools*
The moose likes Struts and the fly likes struts1.1 and tomcat 5.5.27 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts1.1 and tomcat 5.5.27" Watch "struts1.1 and tomcat 5.5.27" New topic
Author

struts1.1 and tomcat 5.5.27

Marcus Halberstram
Greenhorn

Joined: Mar 21, 2009
Posts: 19
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

Joined: Jan 10, 2002
Posts: 61768
    
  67

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Mar 21, 2009
Posts: 19
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Mar 21, 2009
Posts: 19
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Mar 21, 2009
Posts: 19
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Mar 21, 2009
Posts: 19
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

Joined: Sep 29, 2008
Posts: 12617

That'll be a pretty major issue, yes. Without it there's no way for Struts to know it should process any requests.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts1.1 and tomcat 5.5.27