• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get an ArrayList Object in servlet from JSP?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have any form in your page?
Are you using submit button to submit the request to the servlet?

Please read about request lifecycle.

[edited after googling around]

I tried to get some link on it for a while. But no success. So, just take this statement.

When you request to servlet by submitting a page via html submit button or javascript submit function then it would be a brand new request. The old request object will be vanished.
[ June 10, 2005: Message edited by: Adeel Ansari ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JSP is generally the last component in the request chain.
As Adeel mentioned, this is not the place to add things to a request object unless you are forwarding back to the servlet again before sending the output to the browser.
reply
    Bookmark Topic Watch Topic
  • New Topic