Here is the JSP code
<!--
Displays data fro update
-->
<%@ page language="java" contentType="text/html" %>
<%@ page info="report request page" %>
<html>
<head><title>Report Selection</title></head>
<body bgcolor="gray">
<jsp:useBean id="dataentry" class="app.BscmDataEntryBean" scope="session" />
</jsp:useBean>
<form action="/bscm/BscmDataEntryServlet" METHOD="POST">
<TABLE>
<%
int numCol = dataentry.getnumCol();
String[] columnNames = dataentry.getcolumnNames();
String[] xcolumnValue= dataentry.getcolumnValue();
%>
<%
for (int j=0; j < numCol; j++)
{
%>
<TR> <TD>
<% out.println(columnNames[j] );
%>
</TD><TD> </TD> <TD><input type="text" name=xcolumnValue[j]
value="<%= xcolumnValue[j] %>"> </input></TD> </TR>
<% };
%>
<TR></TR><TR>
<TD COLSPAN=3> <input type="submit" name="submit" value="process"> </TD>
<td><input type="hidden" name="process" value="yes"> </td> <%
dataentry.setcolumnValue(xcolumnValue); %> </TR>
</TABLE> <jsp:setProperty name="dataentry" property="columnValue" param=
"xcolumnValue" />
</form>
</body>
</html>
I am calling the "setattrr" method of bean to set one bean attribute. I am
also using "setProperty" tag to update the same attribute in the JSP. But
neither works.
Regards
Sanjay Jain
-----Original Message-----
From: Richard Yee [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 03, 2001 5:54 PM
To: [EMAIL PROTECTED]
Subject: Re: passing bean from JSP to servlet
Sanjay,
The little bit of JSP code that you supplied seems to just get values out
of a bean that is stored in Session scope and output it to the page. I'm
guessing that somewhere you have a html form that allows a user to enter
some data. This form can either submit to a JSP or a Servlet. Regardless
of whichever one you choose, it will have process the form data and
probably update your bean. In some cases its easier to do this in a
JSP. As a general rule though, you should try and keep Java code out of
your JSP pages. Keep the code in custom tags and Java Beans.
If you use a servlet, you will use HttpRequest.getParameter(). If you use
a JSP, you may have the JSP container fill in a bean with your form values
if the field names in the form match the member variable names in your bean.
You'll need to send the rest of your JSP page in order for us to debug your
problem.
Regards,
Richard
At 05:28 PM 12/3/2001 -0500, you wrote:
>Richard,
>
>Thanks for the quick response. I did lookup the archive at JDC, but did not
>find an exact match. Actually I did find one exact posting without any
>response to it.
>
>You said JSP does not update the bean. Is that my JSP code or are you
saying
>JSP in general "can not" update a bean. How does a servlet process form
data
>? Is it the request.getparameter() method that you are referring to ? You
>will have to forgive my ignorance, my exposure to JSP/Servlet is 1 week
old.
>
>
>Thanks again
>
>Sanjay Jain
>
>
>
>-----Original Message-----
>From: Richard Yee [mailto:[EMAIL PROTECTED]]
>Sent: Monday, December 03, 2001 5:07 PM
>To: [EMAIL PROTECTED]
>Subject: Re: passing bean from JSP to servlet
>
>
>Sanjay,
>The JSP is just displaying your data. You say that that is working
>fine. When the user changes the data and submits the form, your servlet
>then needs to process the form data and update the bean. The JSP does not
>update the bean.
>
>Regards,
>
>Richard
>P.S. If you think that a topic has been beaten to death on a forum, it is
>better to look up the problem in the forum archives first rather than post
>it to the forum again.
>
>
>At 04:42 PM 12/3/2001 -0500, you wrote:
> >Greetings !!!
> >
> >This is my first attempt at Web based development. The problem I am about
>to
> >post is a fundamental requirement of any application and am sure the
issue
> >have beaten to death in this forum. So I am hoping for a quick reply.
Here
> >it goes:-
> >
> >1) I instantiate a bean in a servlet and populate it - works fine
> >2) I pass the bean to a JSP which then displays it - works fine
> >3) User updates the displayed data and JSP passes the updated bean back
to
> >servlet. However the servlet receives the old data, not the updated
values
> >
> >Relevant servlet code
> >=====================
> >
> > HttpSession session = request.getSession();
> > app.BscmDataEntryBean changedBean =
>(app.BscmDataEntryBean)
> >session.getAttribute("dataentry");
> >
> > String[] changedColValues=
> >changedBean.getcolumnValue();
> > System.out.println("before displaying new values");
> > System.out.println("new value is " +
changedColValues[0]);
> >
> > System.out.println("new value is " +
changedColValues[1]);
> > System.out.println("new value is " +
changedColValues[2]);
> >
> >
> >Relevant JSP code
> >=================
> >
> ><!--
> > Displays data for update that came from BscmGetReportServlet
> >-->
> >
> ><%@ page language="java" contentType="text/html" %>
> ><%@ page info="report request page" %>
> >
> ><% String[] columnNames = dataentry.getcolumnNames(); int numCol =
> >dataentry.getnumCol(); String[] xcolumnValue= dataentry.getcolumnValue();
> >%> <% for (int j=0; j < numCol; j++) { %>
> ><% out.println(columnNames[j] ); %>
> ><% }; %>
> >
> >
> >I suspect that the JSP does not update the bean, before passing it back
to
> >servlet.
> >
> >
> >Any help will be greatly appreciated.
> >
> >
> >
> >Sanjay Jain
> >
> >
> >
> >
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://archives.java.sun.com/jsp-interest.html
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.jsp
> http://www.jguru.com/faq/index.jsp
> http://www.jspinsider.com
>
>
>***********************************************************************
>Bear Stearns is not responsible for any recommendation, solicitation,
>offer or agreement or any information about any transaction, customer
>account or account activity contained in this communication.
>***********************************************************************
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
> http://archives.java.sun.com/jsp-interest.html
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.jsp
> http://www.jguru.com/faq/index.jsp
> http://www.jspinsider.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
****************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com