Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
|
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 17th, 2005, 04:10 AM
Authorized User
 
Join Date: Oct 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to get vaklue from javabean

Hi,
I would like to know how to assign and display the value to a column name 'item_name' in first.jsp

I have 2 jsp pages - first.jsp , second.jsp. The first.jsp will call the second.jsp and pass in the value. In the second.jsp, I will call the method in the bean file. how do I assign the value and return to the first.jsp.

In second.jsp, i manage the get the value for itemDesc but not sure how to assign this to the column 'item_name' in first.jsp

TQ

The following codes for yr ref
second.jsp
--------------
<jsp:useBean id = "trx" class=".trx.TransDetails" scope="request" />
<% String in_num = request.getParameter("in_num");
String itemDesc = trx.getItem(in_num); // pass in the code and get from database the desc, and return to itemDesc to be display in first.jsp

%>
<script>
window.history.back();
</script>

first.jsp - part of the html body
------------------------------------
<table border="1" width="100%">
<tr>
<th bgcolor="#99CCFF" width="3%">No.</th>
<th bgcolor="#99CCFF" width="15%">Item Code</th>
<th bgcolor="#99CCFF" width="25%">Item Name</th>
</tr>

<%
int i;
for (i=1;i<=5;i++) {%>

<tr>
<td width="3%"><center><%=i%></center></td>
<td width="15%">
<input type="text" name="item_num<%=i%>"
style="width:100%;text-align:left;" maxlength=15
onChange="location.href='second.jsp?in_num='+this. value,
openRow(<%=i%>);">
</td>

<td width="19%">
<input type="text" name="materialDesc<%=i%>"
style="width:100%" value="" disabled>
</td>
</tr>
</table>


 
Old October 24th, 2005, 10:32 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Create setter methods in your bean, then call them as you did your getter method

trx.setItem("yourValue");

setItem must be created in your bean first, something like

public void setItem(String yourItem)
{
  this.item = yourItem;
}

and to return to the first jsp page use

response.sendRedirect("first.jsp");

 
Old December 22nd, 2005, 05:38 AM
Registered User
 
Join Date: Dec 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First and most important thing is that thinking of communication between two web pages is not possible without considering the session. There are three different ways of session management.
1.Cookies
2.URL redirection
3.Session Object

here you can use the third option i.e session object, when u are fetching the description of item from the database immediatally put it into the session veriable and go back to the previous page and get the item desc into the session object.
Hope your probles has been addressed correctly.. B'O L
thank you...








Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write a javabean? yulin11 JSP Basics 3 December 24th, 2007 05:54 AM
Calling javabean onChange event itheiner JSP Basics 1 July 3rd, 2006 05:19 AM
Javamail + form(javabean) octave J2EE 0 February 23rd, 2006 05:37 AM
Using JavaBean with Session Bean siddsonline J2EE 0 April 12th, 2005 07:16 AM
How to implement a javabean data source like this. CSharpKnife Crystal Reports 0 May 21st, 2004 12:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.