• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

servlet action is not availbe

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Possibilities
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags and limit posted code to relevant portions only--that's around 255 lines, many of which are superfluous Javadocs.
reply
    Bookmark Topic Watch Topic
  • New Topic