wood burning stoves*
The moose likes Struts and the fly likes A Problem in struts 1.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "A Problem in struts 1.1" Watch "A Problem in struts 1.1" New topic
Author

A Problem in struts 1.1

Ankit Tripathi
Ranch Hand

Joined: Oct 17, 2009
Posts: 198

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

import java.sql.Connection;
import java.sql.*;
import java.util.*;
import javax.sql.*;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.MyForm;

/**
* MyEclipse Struts
* Creation date: 10-17-2009
*
* XDoclet definition:
* @struts.action path="/my" name="myForm" input="/index.jsp" scope="request" validate="true"
* @struts.action-forward name="Regret" path="/Regret.jsp"
* @struts.action-forward name="Success" path="/Welcome.jsp"
*/
public class MyAction extends Action {
/*
* Generated Methods
*/

/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
MyForm myForm = (MyForm) form;// TODO Auto-generated method stub
String name=myForm.getName();
String password=myForm.getPassword();
try
{
DataSource ds=getDataSource(request,"k1");
Connection con=ds.getConnection();
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select * from etable where name=? and password=?");

while(rs.next())
{
String n=rs.getString("name");
String p=rs.getString("pasword");

if(n.equals("name")&& p.equals("password") )
{
return mapping.findForward("Success");
}
else
return mapping.findForward("Regret");
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
what is the error in the code shown above?it is telling me that method should return a result type of 'ActionForward'!




David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The error message is correct.
Ankit Tripathi
Ranch Hand

Joined: Oct 17, 2009
Posts: 198
sir please tell me why error message is right?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Not all execution paths return an ActionForward.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: A Problem in struts 1.1
 
Similar Threads
update query
change password
session problem
password hashingsalting in struts
Can't create connection with oracle