hi,
i want to return the object of action errors from mu action class then how can i return it because i am already returning the
"return mapping.findForward(target);"
my code is shown below:-
package classes.com.virtualclass.struts;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class LoginAction extends Action {
public static
String getUserName(String login_name, String password, String table) throws Exception {
try {
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
} catch (Exception e1) {
}
String user = "This is only due to some tech problems";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
conn = DriverManager.getConnection("jdbc

b2:first", "", "");
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM ANIL."+table+" WHERE "
+ "ANIL."+table+".LOGIN_NAME = '"+login_name+"'"
+ " AND "+"ANIL."+table+".PASSWORD = '"+password+"'");
if (rs.next()) {
user = rs.getString("login_name");
}
} catch (SQLException e) {
}
conn.close();
return user;
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String target = null;
String user = null;
// Extract attributes and parameters we will need
LoginForm loginForm = (LoginForm)form;
String login_name = loginForm.getLogin_name();
String password = loginForm.getPassword();
String table = loginForm.getLoginas();
user = getUserName(login_name,password,table);
if ((user.equals("This is only due to some tech problems" )) ) {
target = "failure";
ActionErrors errors = new ActionErrors();
errors.add("User Name",
new ActionError("errors.unknown.login_name"));
}
else {
if(table.equalsIgnoreCase("students"))
target="students";
else if(table.equalsIgnoreCase("faculty"))
target="faculty";
else
target="failure";
HttpSession session = request.getSession();
String no = "no";
session.setAttribute("USER", user);
request.setAttribute("no",no );
}
request.setAttribute("user",user);
return mapping.findForward(target);
}
}
Thanks in advance.