File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Error message in struts application requested resource is not available Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Error message in struts application requested resource is not available" Watch "Error message in struts application requested resource is not available" New topic
Author

Error message in struts application requested resource is not available

Booma Devi
Ranch Hand

Joined: Nov 02, 2011
Posts: 61
Hi

I got the warning message in the struts.xml file as below

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

-----> The file cannot be validated as there was a connection problem.

<struts-config>
<form-beans>
<form-bean name="LoginForm" type="Index.html" />
</form-beans>

<action-mappings>
<action path="/login" validate="true" type="com.revathi.action.WelcomeAction">
<forward name="success" path="/success.do" />

</action>
</action-mappings>
</struts-config>


web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>TestStruts</display-name>
<servlet>
<description>
</description>
<display-name>success</display-name>
<servlet-name>success</servlet-name>
<servlet-class>
com.revathi.success.success</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>success</servlet-name>
<url-pattern>/success</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>


Index.html:


<!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 to Struts Application</title>
</head>
<body>
<form action="check.do" method="post">
Enter the username <input type="text" name="uname" />
<input type="submit" value="submit" />
</form>
</body>
</html>

WelcomeAction.java:

package com.revathi.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

public class WelcomeAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest req,HttpServletResponse res)
{
String name=req.getParameter("uname");
if(name.equals("test"))
{
return mapping.findForward("success");

}
else
{
return mapping.findForward("error");
}
}

}

success.java:

package com.revathi.success;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
/**
* Servlet implementation class success
*/
public class success extends HttpServlet {



protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}


protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<body>");
out.println("Thank you for registering");


}

}



After starting the tomcat and type the URL in the browser (http://localhost:8080//testStruts/Index.htm i got the below error message

HTTP Status 404 - /TestStruts/Index.do

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

type Status report

message /TestStruts/Index.do

description The requested resource (/TestStruts/Index.do) is not available.


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

Apache Tomcat/6.0.20


Help me to resolve this...
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

It's better to keep the tld files in the project. so download the required tld files and specify the path where you keep those files.


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Booma Devi
Ranch Hand

Joined: Nov 02, 2011
Posts: 61
Thank you so much for your response.. I will try and let me know...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Error message in struts application requested resource is not available