Reputation: 306
A simple hello world application is showing http-404 error.
I am using the tools below:
1) Eclipse Luna 4.4
2) Apcache tomcat 7.0
3) JDK 7
Application structure
index.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>Simple form</title>
</head>
<body>
<form action="Myaction" method="get">
<input type="text" name="t1"><br>
<input type="submit" value="GO">
</form>
</body>
</html>
Myaction.java
package com.Action;
public class Myaction {
String t1;
public String getT1(){
return t1;
}
public void setT1(String t1) {
this.t1 = t1;
}
public String execute(){
System.out.println(t1);
return "success";
}
}
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>
<constant name="struts.devMode" value="true" />
<package name="default" extends="struts-default">
<action name="Myaction" class="com.Action.Myaction" method="execute">
<result name="success" type="redirect">/Welcome.jsp</result>
</action>
</package>
</struts>
Welcome.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!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>Welcome | Home</title>
</head>
<body>
<label>Welcome -> <s:property value="t1"/> </label>
</body>
</html>
The Markers showing this warnings
<s:property>
-- is not found in build path
Also, server showing the error: resource not available how to solve this error ?
Thanks
Upvotes: 1
Views: 1022
Reputation: 306
The solution is :
In the web project
1) Go to Build Path-configure build path
2) If you are using external JRE then it will give Http 404 error, so I used JDK i.e. Add library- Libraries- Installed JREs
3) Give path of JDK. (We have to use internal JRE)
4) Finish
5) Refresh the project
And it will work..
Upvotes: 1
Reputation: 48
Try extracting struts-.dtd from strut2.core-version.jar into WEB-INF/classes & re-run the project.
Upvotes: 0