Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

HTTP Status 404 error -- The requested resource is not available.

843841Dec 10 2007 — edited Jun 12 2008
Hi ,
i am trying to run a sample struts2 program using java1.5 , tomcat5.5 but getting the error ...
* The requested resource (/Struts2Sample/) is not available.*

i am listing my files below.. kindly help...

web.xml -----------------

<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<display-name>Struts2Sample</display-name>

<filter>
<filter-name>struts</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
<filter-name>struts</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<servlet>
<servlet-name>home</servlet-name>
<jsp-file>HelloWorld.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>home</servlet-name>
<url-pattern>/home</url-pattern>
</servlet-mapping>

</web-app>


struts.xml ---------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="example" extends="struts-default" namespace="/">
<action name="HelloWorld" class="example.HelloWorld">
<result>/HelloWorld.jsp</result>
</action>
</package>

</struts>


HelloWorld.jsp ----------------------

<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Struts 2 Hello World Application!</title>
</head>
<body>
<h2><s:property value="message" /></h2>
<p>Current date and time is: <b><s:property value="currentTime" /></b>
</body>
</html>


ExampleSupport.java ---------------------------

package example;
import com.opensymphony.xwork2.ActionSupport;

/**
* Base Action class for the Tutorial package.
*/
public class ExampleSupport extends ActionSupport {
}


HelloWorld.java --------------------

package example;
public class HelloWorld extends ExampleSupport {

public String execute() throws Exception {
setMessage(getText(MESSAGE));
return SUCCESS;
}

/**
* Provide default valuie for Message property.
*/
public static final String MESSAGE = "HelloWorld.message";

/**
* Field for Message property.
*/
private String message;

/**
* Return Message property.
*
* @return Message property
*/
public String getMessage() {
return message;
}

/**
* Set Message property.
*
* @param message Text to display on HelloWorld page.
*/
public void setMessage(String message) {
this.message = message;
}
}



My directory structure ....

D:\tomcat5.5\webapps\Struts2Sample ---- this has my jsp file.
D:\tomcat5.5\webapps\Struts2Sample\src\example ---- this has both java source files..
D:\tomcat5.5\webapps\Struts2Sample\WEB-INF\classes\example ---- this has compiled class files
D:\tomcat5.5\webapps\Struts2Sample\WEB-INF\classes ---- this has my struts.xml file
D:\tomcat5.5\webapps\Struts2Sample\WEB-INF\lib ---- this has all my jars..
D:\tomcat5.5\webapps\Struts2Sample\WEB-INF --- this has my web.xml file

kindly let me know i am making mistakes if any...
i am using url as : http://localhost:8080/Struts2Sample/

Thanks,
Nads
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 10 2008
Added on Dec 10 2007
1 comment
235 views