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 servlet action is not availbe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "servlet action is not availbe " Watch "servlet action is not availbe " New topic
Author

servlet action is not availbe

mahendranag manchina
Greenhorn

Joined: Aug 03, 2009
Posts: 2
Hello

please slove this for me ,,


this is my jsp page
<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>

<html>
<head>
<title>JSP for LoginForm form</title>
</head>
<body>
<html:form action="/login" method="post">
username : <html:text property="username"/><html:errors property="username"/>

password : <html:password property="password"/><html:errors property="password"/>

<html:submit/><html:cancel/>

</html:form>
</body>
</html>

This is my form
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

/**
* MyEclipse Struts
* Creation date: 07-31-2009
*
* XDoclet definition:
* @struts.form name="loginForm"
*/
public class LoginForm extends ActionForm {
/*
* Generated fields
*/

/**
*
*/
private static final long serialVersionUID = 1L;

/** password property */
private String password;

/** username property */
private String username;

/*
* Generated Methods
*/

/**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
}

/**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}

/**
* Returns the password.
* @return String
*/
public String getPassword() {
return password;
}

/**
* Set the password.
* @param password The password to set
*/
public void setPassword(String password) {
this.password = password;
}

/**
* Returns the username.
* @return String
*/
public String getUsername() {
return username;
}

/**
* Set the username.
* @param username The username to set
*/
public void setUsername(String username) {
this.username = username;
}
}

ANd this is my action class
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.action;




import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


import com.yourcompany.struts.form.LoginForm;

/**
* MyEclipse Struts
* Creation date: 07-31-2009
*
* XDoclet definition:
* @struts.action path="/login" name="loginForm" input="/form/login.jsp" scope="request" validate="true"
* @struts.action-forward name="failure" path="/form/login.jsp" redirect="true"
* @struts.action-forward name="sucess" path="/form/regist.jsp" redirect="true"
*/
public class LoginAction extends Action {


public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws SQLException
{

LoginForm loginForm = (LoginForm) form;
DataSource dataSource;
Connection con;
dataSource = getDataSource(request);
con = dataSource.getConnection();
Statement stmt=con.createStatement();
ResultSet rst=stmt.executeQuery("select username,password from login");
while(rst.next())
{
System.out.println(rst.getString("username"));
System.out.println(rst.getString("password"));
}
if(loginForm.getUsername().equals("username")&&(loginForm.getPassword().equals("password")))
{
return mapping.findForward("sucess");
}
else
{
return mapping.findForward("failure");
}
}
}



and this my struts-config.xml

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

<struts-config>

<data-sources>
<data-source key="org.apache.struts.action.DATA_SOURCE" type="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
<set-property property="minCount" value="" />
<set-property property="password" value="mahendra" />
<set-property property="maxCount" value="" />
<set-property property="user" value="root" />
<set-property property="driverClass" value="com.mysql.jdbc.Driver" />
<set-property property="description" value="mysql" />
<set-property property="url" value="jdbc:mysql://localhost:3306/test" />
<set-property property="autoCommit" value="true" />
<set-property property="readOnly" value="false" />
<set-property property="loginTimeout" value="" />
</data-source>

</data-sources>
<form-beans >
<form-bean name="loginForm" type="com.yourcompany.struts.form.LoginForm" />
<form-bean name="sourceForm" type="com.yourcompany.struts.form.SourceForm" />
<form-bean name="registForm" type="com.yourcompany.struts.form.RegistForm" />



</form-beans>

<global-exceptions />
<global-forwards >


</global-forwards>

<action-mappings>
<action
attribute="loginForm"
input="/form/login.jsp"
name="loginForm"
path="/login"
scope="request"
type="com.yourcompany.struts.action.LoginAction">
<forward
name="failure"
path="/form/login.jsp"
redirect="true" />
<forward
name="sucess"
path="/regist.jsp"
redirect="true" />
</action>
<action
attribute="registForm"
input="/regist.jsp"
name="registForm"
path="/regist"
scope="request"
type="com.yourcompany.struts.action.RegistAction">
<forward
name="failure"
path="/regist.jsp"
redirect="true" />
<forward
name="sucess"
path="/source.jsp"
redirect="true" />
</action>
</action-mappings>
<message-resources parameter="com.yourcompany.struts.ApplicationResources" />

</struts-config>

,,,and iam getting this error servlet action not availbe any body slove this for me please
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575


Possibilities
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags and limit posted code to relevant portions only--that's around 255 lines, many of which are superfluous Javadocs.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet action is not availbe