aspose file tools*
The moose likes Struts and the fly likes Help Me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Help Me" Watch "Help Me" New topic
Author

Help Me

Pawan Ramchandani
Ranch Hand

Joined: Aug 15, 2003
Posts: 78
Hello,

I am using struts-dbcp to connect with mysql database when i compile my appication and run it i able to see login page but when i submit it tomcat shows error HTTP Status-500 Servlet action is not available.All required jar including commons-dbcp,commons-pool,struts-legacy is in the lib folder ad structutre of the application is as follows.

****************
INDEX PAGE
****************

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html:html>
<head>
<title>
<bean:message key="app.title"/>
</title>
</head>
<body bgcolor="#c0c0c0">
<html:errors/>
<h1>
Welcome
</h1>
<html:form action="/loginAction" method="post">
<bean:message key="app.pass"/><html assword property="pass" size="18"></html assword>
<br/><bean:message key="app.email"/><html:text property="email" size="18"></html:text>
<br><br>
<html:submit value="Submit" property="submit"/>
<html:reset value="Reset"/>
</html:form>
</body>
</html:html>

**************
ACTION FORM
**************

package testing_code;

import org.apache.struts.validator.ValidatorForm;
import javax.servlet.http.*;

public class LoginActionForm extends ValidatorForm
{
private String email;
private String pass;

public String getEmail()
{
return email;
}

public void setEmail(String email)
{
this.email = email;
}

public String getPass()
{
return pass;
}

public void setPass(String pass)
{
this.pass = pass;
}
}

**************
ACTION
**************

package testing_code;

import javax.sql.DataSource;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.sql.*;

public class LoginAction extends Action
{
DataSource ds=null;
Connection con=null;
Statement stmt=null;
ResultSet rs=null;
String name="";
String pass="";
String email="";

public ActionForward execute(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse httpServletResponse)
{
try
{
ds = getDataSource(request);
con = ds.getConnection();
stmt=con.createStatement();

LoginActionForm dyna = (LoginActionForm) actionForm;
pass=dyna.getPass();
email=dyna.getEmail();

rs=stmt.executeQuery("Select * from tn_User where pass='"+pass+"',email'"+email+"'");
if(rs.next())
return mapping.findForward("pass");
else
return mapping.findForward("fail");
}
catch(Exception e)
{
e.getMessage();
return mapping.findForward("fail");
}
}
}


**************
SERVLET-CONFIG
**************
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<data-sources>
<data-source key="Database" type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="org.gjt.mm.mysql.Driver" />
<set-property property="url" value="jdbc:mysql://lancashire/Test" />
<set-property property="username" value="root" />
<set-property property="password" value=" " />
</data-source>
</data-sources>
<form-beans>
<form-bean name="loginActionForm" type="testing_code.LoginActionForm" />
</form-beans>
<action-mappings>
<action input="/index.jsp" name="loginActionForm" path="/loginAction" scope="session" type="testing_code.LoginAction">
<forward name="pass" path="/userSuccess.jsp" />
<forward name="fail" path="/userFailure.jsp" />
</action>
</action-mappings>
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml" />
</plug-in>
</struts-config>

***************
WEB.XML
***************

<?xml version="1.0" encoding="UTF-8"?>
<!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>Testing</display-name>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-template.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-template.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
</web-app>


**************
TOMCAT ERROR.LOG
**************

StandardWrapperValve[action]: Servlet action is currently unavailable

pls. help me i am unable to find any error.

Thanks in advance


Pawan Ramchandani<br />*******************************<br />SCJP 1.4<br />SCWCD <br />*******************************<br />Everything is okay in the end. If it's not okay, then it's not the end.
Pawan Ramchandani
Ranch Hand

Joined: Aug 15, 2003
Posts: 78
Any reply
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help Me