Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!

Gopnan

Greenhorn
+ Follow
since Sep 13, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gopnan

Hi Firends,
I am new to struts application. I don't know what is use ActionErrors and ActionError and how to use this Errors in our Struts application .Anybody help to me. Give a sample code for how to use this.
16 years ago
Dear Freinds,

I am new to Struts application. I don't know how to set array values set into the checkbox and radio button tag. I get values from database and set the values into array list. I set this set of array list values into jsp page checkbox or radio button option. I don't know how to set it. Please any body help me. Pls give an example code for this.
16 years ago
Hi Sterling,

In id is the value fetch from database. I set that id value to my form field like (sf.setStaffid(id)). That id value will be display to my next jsp page when i was click registration form. I get id value from database and i set that value in to form field in Action class. But i don't know how can i show that value in my next jsp page textbox.

sf--> StaffForm object
staffid --> String variable
16 years ago
Hi Friends,
I am new to struts.I would like to set value into <html:text > in my next struts jsp page. But i don't know how to set it? Can anybody to say how to set this?

<bean:write name="staffForm" property="staffid"/>

<html:text property="staffid" value="" />

My actual fact is one sequence number is generated when i am creating new user . i can set that number into <html:text> in my new user creating page.pls help me.
16 years ago
Hi kailash,

<display:table name="loginForm" property="vect">
<display:column property="name" title="Name"></display:column>
<display:column property="address" title="Address"></display:column>
<display:column property="phone" title="Phone"></display:column>
</display:table>

LoginForm is the name of form
vect is a collection Object name
name,address,phone fields are required properties
16 years ago
Hai friends,

I try to use html:multibox tag , html:checkbox tag it's throw bellow exception. i don't know what is the problem? pls say something about these problem to rectifying.

Exception
javax.servlet.ServletException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471)
at org.apache.jsp.data$jsp._jspService(data$jsp.java:179)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:534)
root cause
javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
at org.apache.struts.taglib.html.MultiboxTag.doEndTag(MultiboxTag.java:236)
at org.apache.jsp.data$jsp._jspService(data$jsp.java:152)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
16 years ago
Senthil,
Already i was put disply.tld in my web-inf folder. I don't know what type of jar file i put in my lib directory. can you say, the type of jar file or display.tld is enough for this please say something to this.

display.tld

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>display</shortname>
<uri>http://jakarta.apache.org/taglibs/display</uri>;
<info>
A description of the display tag library goes here...
</info>
<tag>
<name>table</name>
<tagclass>org.apache.taglibs.display.TableTag</tagclass>
<teiclass>org.apache.taglibs.display.TableTagExtraInfo</teiclass>
<bodycontent>JSP</bodycontent>
<attribute>
<name>list</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>name</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>property</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>scope</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>length</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>offset</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>pagesize</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>decorator</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>requestURI</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>width</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>styleClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>border</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>cellspacing</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>cellpadding</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>align</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>background</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>bgcolor</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>frame</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>height</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>hspace</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>rules</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>summary</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>vspace</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>export</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>display</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>column</name>
<tagclass>org.apache.taglibs.display.ColumnTag</tagclass>
<bodycontent>JSP</bodycontent>
<attribute>
<name>property</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>value</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>title</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>nulls</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>sort</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>autolink</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>href</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>paramId</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>paramName</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>paramProperty</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>paramScope</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>maxLength</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>maxWords</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>width</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>styleClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>headerStyleClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>align</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>background</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>bgcolor</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>height</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>nowrap</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>valign</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>group</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>doubleQuote</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>decorator</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag>
<name>setProperty</name>
<tagclass>org.apache.taglibs.display.SetPropertyTag</tagclass>
<bodycontent>JSP</bodycontent>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
16 years ago
Dear Senthil,
In my Jsp i wrote these code, but it thrown some exception, i don't know how to solve this. could you say, something to solve this.

data.jsp

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/display.tld" prefix="display" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
<head>
<html:base />
<title>data jsp</title>
</head>

<body>
<display:table property="vect" name="loginForm" align="center" >
<display:column property="name" title="Name" />
<display:column property="address" title="Address" />
<display:column property="phone" title="Phone" />
</display:table>
</body>
</html:html>

LoginAction.java

package stu;

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.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.Globals;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.sql.DataSource;
import java.util.Vector;

public class LoginAction extends Action {
Connection con = null;
Statement st = null;
ResultSet rs = null;
boolean result = false;
Vector vec = new Vector();
int id = 0;
String name = "";
String address = "";
int phone = 0;
String dt="" ;
boolean user ;

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getDt() {
return dt;
}

public void setDt(String dt) {
this.dt = dt;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getPhone() {
return phone;
}

public void setPhone(int phone) {
this.phone = phone;
}

public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) {
LoginForm lf = (LoginForm)form;
HttpSession session = request.getSession();
String username = lf.getLogin();
String password = lf.getPassword();
DataSource dataSource = (DataSource) servlet.getServletContext().getAttribute(Globals.DATA_SOURCE_KEY);
try{
con = dataSource.getConnection();
st = con.createStatement();
if(username.length()>0 && password.length()>0){
login log = new login(st);
user=log.userChecking(username,password);
if(user)
vec = log.getRecords();
lf.setVect(vec);
lf.setLogin(username);
return mapping.findForward("success");
}
}catch(Exception e){
System.out.println("Error "+e);
}
return mapping.findForward("failure");
}
}

login.class

package stu;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import org.apache.struts.action.ActionMapping;
import javax.sql.DataSource;
import java.util.*;

public class login {
Connection con=null;
Statement st = null;
ResultSet rs = null;
DataSource dataSource;
ActionMapping mapping=null;
Vector vec = new Vector();
boolean user =false;
String name="";
String address="";
int phoneno=0;
String datee="";

login(){

}

public login(Statement st){
this.st = st;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getDatee() {
return datee;
}

public void setDatee(String datee) {
this.datee = datee;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getPhoneno() {
return phoneno;
}

public void setPhoneno(int phoneno) {
this.phoneno = phoneno;
}

public boolean userChecking(String username,String password){
try{
String query = "select username,password from tbluser where username='"+username+"' and password='"+password+"'";
rs = st.executeQuery(query);
if(rs.next()){
user = true;
return user;
}

}catch(Exception e){
System.out.println("Error "+e);
}
return user;
}
public Vector getRecords(){
try{
String query1 = "select * from tbldata";
rs = st.executeQuery(query1);
while(rs.next()){
LoginForm lf = new LoginForm();
lf.setName(rs.getString("name"));
lf.setAddress(rs.getString("address"));
lf.setPhone(rs.getInt("phoneno"));
lf.setDate(rs.getString("date"));
vec.addElement(lf);
}
}catch(Exception e){
System.out.println("Error "+e);
}
return vec;
}
}

LoginForm.java

package stu;

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

public class LoginForm extends ActionForm {

private String password;
private String login;
private Vector vect;
private List list;
private String name;
private String address;
private int phone;
private String date;

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getDate() {
return date;
}

public void setDate(String date) {
this.date = date;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getPhone() {
return phone;
}

public void setPhone(int phone) {
this.phone = phone;
}

public List getList() {
return list;
}

public void setList(List list) {
this.list = list;
}

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

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

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getLogin() {
return login;
}

public void setLogin(String login) {
this.login = login;
}

public Vector getVect() {
return vect;
}

public void setVect(Vector vect) {
this.vect = vect;
}
}

but it raised these exeception

org.apache.jasper.compiler.CompileException: /data.jsp(25,1) Unable to load class org.apache.taglibs.display.TableTag
at org.apache.jasper.compiler.TagBeginGenerator.init(TagBeginGenerator.java:139)
at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.init(JspParseEventListener.java:829)
at org.apache.jasper.compiler.JspParseEventListener.addGenerator(JspParseEventListener.java:153)
at org.apache.jasper.compiler.JspParseEventListener.handleTagBegin(JspParseEventListener.java:1039)
at org.apache.jasper.compiler.DelegatingListener.handleTagBegin(DelegatingListener.java:221)
at org.apache.jasper.compiler.DelegatingListener.handleTagBegin(DelegatingListener.java:216)
at org.apache.jasper.compiler.Parser$Tag.accept(Parser.java:878)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1145)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1103)
at org.apache.jasper.compiler.Parser$Tag.accept(Parser.java:892)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1145)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1103)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1099)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:214)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:210)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:176)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:188)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:534)

can you give me a some suggestions.
16 years ago
Hi Ranjith,

Thank you very much, Now it's working fine. Could you say, how to set that same type collection values in to a display table Tag. Actually In my jsp code i wrote these

<display:table property="vect" name="loginForm" align="center" >
<display:column property="name" title="Name" />
</display:table>

but i raised these exeception

org.apache.jasper.compiler.CompileException: /data.jsp(25,1) Unable to load class org.apache.taglibs.display.TableTag
at org.apache.jasper.compiler.TagBeginGenerator.init(TagBeginGenerator.java:139)
at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.init(JspParseEventListener.java:829)
at org.apache.jasper.compiler.JspParseEventListener.addGenerator(JspParseEventListener.java:153)
at org.apache.jasper.compiler.JspParseEventListener.handleTagBegin(JspParseEventListener.java:1039)
at org.apache.jasper.compiler.DelegatingListener.handleTagBegin(DelegatingListener.java:221)
at org.apache.jasper.compiler.DelegatingListener.handleTagBegin(DelegatingListener.java:216)
at org.apache.jasper.compiler.Parser$Tag.accept(Parser.java:878)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1145)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1103)
at org.apache.jasper.compiler.Parser$Tag.accept(Parser.java:892)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1145)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1103)
at org.apache.jasper.compiler.Parser.parse(Parser.java:1099)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:214)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:210)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:548)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:176)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:188)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:534)

can you give me a some suggestions.
16 years ago
Hi Ranjith,

I send my struts-config and action methods with this mail. please give some suggestion what can i do for?

struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<data-sources >
<data-source key="org.apache.struts.action.DATA_SOURCE">
<set-property property="password" value="" />
<set-property property="minCount" value="1" />
<set-property property="maxCount" value="4" />
<set-property property="user" value="" />
<set-property property="driverClass" value="sun.jdbc.odbc.JdbcOdbcDriver" />
<set-property property="description" value="Struts Test" />
<set-property property="url" value="Jdbc dbc river={Microsoft Access Driver (*.mdb)};DBQ=C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\Struts\StrutsDB.mdb" />
<set-property property="readOnly" value="false" />
<set-property property="autoCommit" value="false" />
<set-property property="loginTimeout" value="" />
</data-source>
</data-sources>

<form-beans >
<form-bean name="loginForm" type="LoginForm" id="logtodata">
</form-bean>
</form-beans >

<global-exceptions />
<global-forwards />
<action-mappings >
<action attribute="LoginForm" name="loginForm" path="/register" scope="request" type="LoginAction" parameter="log" >
<forward name="success" path="/data.jsp" />
</action>
</action-mappings>

<message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>

LoginAction.java

import javax.mail.Session;
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.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.Globals;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.sql.DataSource;
import java.util.Vector;

public class LoginAction extends Action {
Connection con = null;
Statement st = null;
ResultSet rs = null;
boolean result = false;
Vector vec = new Vector();
int id = 0;
String name = "";
String address = "";
int phone = 0;
String dt="" ;
boolean user ;

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getDt() {
return dt;
}

public void setDt(String dt) {
this.dt = dt;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getPhone() {
return phone;
}

public void setPhone(int phone) {
this.phone = phone;
}

public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) {
LoginForm lf = (LoginForm)form;
HttpSession session = request.getSession();
String username = lf.getLogin();
String password = lf.getPassword();
DataSource dataSource = (DataSource) servlet.getServletContext().getAttribute(Globals.DATA_SOURCE_KEY);
try{
con = dataSource.getConnection();
st = con.createStatement();
if(username.length()>0 && password.length()>0){
login log = new login(st);
user=log.userChecking(username,password);
if(user)
vec = log.getRecords();
lf.setVect(vec);
lf.setLogin(username);
return mapping.findForward("success");
}
}catch(Exception e){
System.out.println("Error "+e);
}
return mapping.findForward("failure");
}
}

login.java

import java.io.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionMapping;
import javax.sql.DataSource;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class login {
Statement st = null;
ResultSet rs = null;
DataSource dataSource;
ActionMapping mapping=null;
Vector vec = new Vector();
boolean user =false;
String name="";
String address="";
int phoneno=0;
String datee="";

login(){
}

public login(Statement st){
this.st = st;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public String getDatee() {
return datee;
}

public void setDatee(String datee) {
this.datee = datee;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getPhoneno() {
return phoneno;
}

public void setPhoneno(int phoneno) {
this.phoneno = phoneno;
}

public boolean userChecking(String username,String password){
try{
String query = "select username,password from tbluser where username='"+username+"' and password='"+password+"'";
rs = st.executeQuery(query);
if(rs.next()){
user = true;
return user;
}

}catch(Exception e){
System.out.println("Error "+e);
}
return user;
}

public Vector getRecords(){
LoginAction la = new LoginAction();
try{
String query1 = "select * from tbldata";
rs = st.executeQuery(query1);
while(rs.next()){
la.setName(rs.getString("name"));
la.setAddress(rs.getString("address"));
la.setPhone(rs.getInt("phoneno"));
la.setDt(rs.getString("date"));
vec.addElement(la);
}
}catch(Exception e){
System.out.println("Error "+e);
}
return vec;
}
}

LoginForm.java

/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import java.util.*;

public class LoginForm extends ActionForm {
private String password;
private String login;
private Vector vect;
private List list;

public List getList() {
return list;
}

public void setList(List list) {
this.list = list;
}

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

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

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getLogin() {
return login;
}

public void setLogin(String login) {
this.login = login;
}

public Vector getVect() {
return vect;
}

public void setVect(Vector vect) {
this.vect = vect;
}
}

data.jsp

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-display.tld" prefix="display" %>

<html:html>
<head>
<title><bean:message key="login.title" />
</title>
</head>
<body>
<table border="1">
<tr>
<th>Name</th>
<th>Address</th>
<th>Phone No</th>
<th>Date</th>
</tr>
<logic:iterate id="result" name="loginForm" property="vect" >
<tr>
<td><bean:write name="result" property="name"/></td>
<td><bean:write name="result" property="address"/></td>
<td><bean:write name="result" property="phone"/></td>
<td><bean:write name="result" property="dt"/></td>
</tr>
</logic:iterate>
<table>
</body>
</html:html>
16 years ago
Hi friends,
I am new to Struts, i get one collection object value(like vector) and put that values in logic:iterate but i have some error message try this. any body help me...

my error is

javax.servlet.ServletException: Cannot find bean loginForm in any scope
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:471)
at org.apache.jsp.data$jsp._jspService(data$jsp.java:288)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:534)


root cause

javax.servlet.jsp.JspException: Cannot find bean loginForm in any scope
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:938)
at org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:277)
at org.apache.jsp.data$jsp._jspService(data$jsp.java:134)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:534)

My code is

try{
con = dataSource.getConnection();
st = con.createStatement();
if(username.length()>0 && password.length()>0){
login log = new login(st);
user=log.userChecking(username,password);
if(user)
vec = log.getRecords();
lf.setVect(vec);
lf.setLogin(username);
return mapping.findForward("success");
}
}catch(Exception e){
System.out.println("Error "+e);
}

In jsp

<logic:iterate id="result" name="loginForm" property="vect" >
<tr>
<td><bean:write name="result" property="name"/></td>
<td><bean:write name="result" property="address"/></td>
<td><bean:write name="result" property="phone"/></td>
<td><bean:write name="result" property="dt"/></td>
</tr>
</logic:iterate>
16 years ago
Hi,
My ActionClass return one ArrayList collection, I set that ArrayList in one session. I like display that collection value in my next page with <display:table> tag. I don't know how to use this tag. Any body give me a sample code to me.

By
Nanda
16 years ago
Hi,
I remove that redirect in my struts-config but it also return same value.
16 years ago
Hi,
Thanks for you reply.
I put vector values into session. I got values in my next page(data.jsp page).But it returned last value of the table only with record iteration .
How can i get each record of the table. Pls give a solution
16 years ago
Hi,
I am new to Struts. when i try to get collection value from Action Class to my next jsp page i got that bellow error:
javax.servlet.ServletException: Cannot find bean loginForm in any scope
Any body please help me, i give my code also

Login.jsp

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html locale="true">
<head>
<html:base />
<title><bean:message key="login.title"/></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="-1">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
</head>
<body>
<html:form action="register.do" method="post" focus="login">
<table border="0">
<tr>
<td><bean:message key="login.username"/></td>
<td><html:text property="login"/></td>
</tr>
<tr>
<td><bean:message key="login.password"/></td>
<td><html assword property="password" /></td>
</tr>
<tr>
<td colspan="2" align="center"><html:submit value="Login"/></td>
</tr>
</table>
</html:form>
</body>
</html:html>

LoginForm.java

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

public class LoginForm extends ActionForm {
private String password;
private String login;
private Vector vect;
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
}
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}

public String getLogin() {
return login;
}

public void setLogin(String login) {
this.login = login;
}

public Vector getVect() {
return vect;
}

public void setVect(Vector vect) {
this.vect = vect;
}
}

/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/


import javax.mail.Session;
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.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.Globals;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.sql.DataSource;
import java.util.Vector;


LoginAction.java

public class LoginAction extends Action {
Connection con = null;
Statement st = null;
ResultSet rs = null;
boolean result = false;
Vector vec = new Vector();
boolean user ;

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

LoginForm lf = (LoginForm)form;
HttpSession session = request.getSession();
String username = lf.getLogin();
String password = lf.getPassword();

DataSource dataSource = (DataSource) servlet.getServletContext().getAttribute(Globals.DATA_SOURCE_KEY);
try{
con = dataSource.getConnection();
st = con.createStatement();
if(username.length()>0 && password.length()>0){
login log = new login(st);
user=log.userChecking(username,password);
if(user)
vec = log.getRecords();
lf.setVect(vec);
return mapping.findForward("success");
}
}catch(Exception e){
System.out.println("Error "+e);
}
return mapping.findForward("failure");
}
}

login.java

import java.io.*;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionMapping;
import javax.sql.DataSource;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class login {
ResultSet rs = null;
ActionMapping mapping=null;
Vector vec = new Vector();
boolean user =false;

login(){
}

public login(Statement st){
this.st = st;
}

public boolean userChecking(String username,String password){
try{
String query = "select username,password from tbluser where username='"+username+"' and password='"+password+"'";
rs = st.executeQuery(query);
if(rs.next()){
user = true;
return user;
}

}catch(Exception e){
System.out.println("Error "+e);
}
return user;
}
public Vector getRecords(){
LoginAction la = new LoginAction();
try{
String query1 = "select * from tbldata";
rs = st.executeQuery(query1);
while(rs.next()){
la.setName(rs.getString("name"));
la.setAddress(rs.getString("address"));
la.setPhone(rs.getInt("phoneno"));
la.setDt(rs.getString("date"));
vec.addElement(la);
}
}catch(Exception e){
System.out.println("Error "+e);
}
return vec;
}
}

data.jsp

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/display.tld" prefix="display" %>
<html:html>
<head>
<title><bean:message key="login.title" />
</title>
</head>
<body>
<table border="1">
<tr>
<th>Name</th>
<th>Address</th>
<th>Phone No</th>
<th>Date</th>
</tr>
<logic:iterate id="result" name="loginForm" property="vect">
<tr>
<td><bean:write name="result" property="name"/></td>
<td><bean:write name="result" property="address"/></td>
<td><bean:write name="result" property="phone"/></td>
<td><bean:write name="result" property="dt"/></td>
</tr>
</logic:iterate>
</table>
</body>
</html:html>

struts-config.xml

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

<struts-config>
<data-sources >
<data-source key="org.apache.struts.action.DATA_SOURCE">
<set-property property="password" value="" />
<set-property property="minCount" value="1" />
<set-property property="maxCount" value="4" />
<set-property property="user" value="" />
<set-property property="driverClass" value="sun.jdbc.odbc.JdbcOdbcDriver" />
<set-property property="description" value="Struts Test" />
<set-property property="url" value="Jdbc dbc river={Microsoft Access Driver (*.mdb)};DBQ=C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\Struts\StrutsDB.mdb" />
<set-property property="readOnly" value="false" />
<set-property property="autoCommit" value="false" />
<set-property property="loginTimeout" value="" />
</data-source>
</data-sources>

<form-beans >
<form-bean name="loginForm" type="LoginForm" />
</form-beans >
<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="LoginForm" name="loginForm" path="/register" scope="request" type="LoginAction">
<forward name="success" path="/data.jsp" redirect="true" />
<forward name="failure" path="/Failure.html" redirect="true" />
</action>
</action-mappings>
<message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>


16 years ago