File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error message in struts application requested resource is not available

 
Booma Devi
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 485
Eclipse IDE Firefox Browser Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Booma Devi
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much for your response.. I will try and let me know...
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic