Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in Struts2 while running an application

 
Ishant Agarwal
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Guys!!!

I know struts 1.3 but new in struts2 so i am creating hello world application on struts2 using eclipse(Indigo) with apache tomcat 7

but get an error like

HTTP Status 404 - /struts2/

--------------------------------------------------------------------------------

type Status report

message /struts2/

description The requested resource (/struts2/) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/7.0.14


this is my struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<struts>
<package name="default" extends="struts-default" namespace="/">
<action name="HelloWorld" class="com.controller.HelloWorld">
<result name="SUCCESS">/success.jsp</result>
</action>
</package>
</struts>


this is my Action Support class
package com.controller;

import com.opensymphony.xwork2.ActionSupport;
public class HelloWorld extends ActionSupport{
String message ;
String userName ;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String execute(){
setMessage("Hello " + getUserName()) ;
return "SUCCESS";
}
}


this is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>struts2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>


this is my index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:form action="HelloWorld">
<s:textfield name="userName" label="User Name:"></s:textfield>
<s:submit/>
</s:form>
</body>
</html>

this is my hierarchy

|struts2
| | Java Resources
| | |src
| | | | com.controller
| | | | | HelloWorld.java
| | |resources
| | | | struts.xml
| | build
| | WebContent
| | |WEB_INF
| | | | lib
| | | | | web.xml
| | |index.jsp
| | |success.jsp


Pl help me out

Regards
Ishant
Software Engineer
 
Franck Times
Greenhorn
Posts: 9
Eclipse IDE Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

if you take a look at Tomcat web application manager, can you see you application and does Tomcat says it's running ?

You'll find here some explanations on how to enable Tomcat Web App manager for tomcat 5.5, I guess it's pretty much the same for Tomcat 7

And please use BB code to display your codes, xml files, ... such as :
 
Ishant Agarwal
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your support but i am using an eclipse browser and still getting an same kind of error
 
Franck Times
Greenhorn
Posts: 9
Eclipse IDE Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not a browser issue, rather a server issue. Your app is not found either because:
you did not properly deployed it on Tomcat
or your configuration (web.xml and/or struts.xml) is not valid.

Looking at the Tomcat web app manager would allow you to check if your app was deployed or not, ruling out one of the two possibilities.


Tomcat web app manager is a Tomcat feature which enables you to have a look on what's running on your tomcat server. You said you were using tomcat 7. I guess (I am using tomcat 6) there's a web app manager in T7. Usually you can access it thru : http://localhost:8080/manager/html.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic