• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Servlet Action is not available(Very Urgent)

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any suggestion?
 
Pawan Ramchandani
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any reply?
reply
    Bookmark Topic Watch Topic
  • New Topic