Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Java

Reply
 
LinkBack Thread Tools Display Modes
Old 06-09-2005, 09:54 PM   #1 (permalink)
edwardmraj
Registered User
 
Join Date: Jun 2005
Posts: 3
edwardmraj is on a distinguished road
How to get an ArrayList Object in servlet from JSP?

hi all

please give the solution for this without using session and application...


In test1.jsp file
i am setting values for my setter methods using <jsp:usebean> <jsp:setproperty> tags as shown below.

After that i am adding the usebean object to array list, then using request.setAttribute("arraylist object")


---------Code----------
<jsp:useBean id="payment" class="com.common.PaymentHandler" scope="request" />

<jsp:setProperty name="payment" property="strCreditCardNo" param="creditCardNumber" />
<%-- <jsp:setProperty name="payment" property="iCsc" param="securityCode" /> --%>
<jsp:setProperty name="payment" property="strDate" param="expirationDate" />
<jsp:setProperty name="payment" property="strCardType" param="creditCardType" />
<%--<jsp:setProperty name="payment" property="cDeactivate" param="deactivateBox" />
<jsp:setProperty name="payment" property="fAmount" param="depositAmt" />
<jsp:setProperty name="payment" property="fAmount" param="totalAmtDue" /> --%>


<jsp:useBean id="lis" class="java.util.ArrayList" scope="request">
<%
lis.add(payment);
%>

</jsp:useBean>

<%
request.setAttribute("lis1",lis);
%>
-----------Code in JSP-----------------

In testServlet.java

i tried to get the arraylist object in servlet using request.getAttribute

But I unable to get that arrayObject in servlet.....

So if any one help me out in this, it will be very helpfull to me..

Thanks in Advance

Edward
edwardmraj is offline   Reply With Quote
Old 06-10-2005, 05:55 AM   #2 (permalink)
jeffro
Person of interest
 
jeffro's Avatar
 
Join Date: Mar 2003
Location: New Jersey
Posts: 102
jeffro is on a distinguished road
You can't set properties in the request in a JSP page then access them in the servlet. As soon as you submit the form or change pages, its a new request and your properties aren't there. You either need to pass them in the URL or in a form submission post or get.
__________________
Jeffro
Linux counter#:213782
GnuPG ID: 406238E7
jeffro is offline   Reply With Quote
Old 06-10-2005, 08:15 AM   #3 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,140
Belisarius is on a distinguished road
Jeffro's mainly correct. If you've ruled out using the session and application objects, you've ruled out the simplest way to do this. You could work with the Response object, and then pass that on to the servlet using the "forward()" method. At least I think you can - I haven't done it before. Give it a shot and see if it works.
__________________
GitS
Belisarius is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is a Static Reference to an Object Garbage Collected? dancer Java 1 03-01-2005 10:50 AM


All times are GMT -8. The time now is 02:16 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting