• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A Problem in struts 1.1

 
Ankit Tripathi
Ranch Hand
Posts: 199
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

/*
* 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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message is correct.
 
Ankit Tripathi
Ranch Hand
Posts: 199
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir please tell me why error message is right?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not all execution paths return an ActionForward.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic