Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Converting ResultSet String to ArrayList

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I am developing an application in which I am sending a ResultSet from servlet to jsp page. ResultSet contains result of "select" query and I wanted to dispaly the output of this query in jsp page in table format.
In servlet the output of query is stored in ArrayList and I am sending this ArrayList using <jsp:forward page > tag.
In my jsp page I am getting ResultSet result using request.getParameter("param1").
Now I wanted to convert this request.getParameter("param1") to ArrayList and get its Attribute.
Can Anybody tell me how to achieve this?

Code for reference:





when I am printing values in JSP page using out.println(request.getParameter("param1")); are

[{STATUS=open, FUNCTIONAL_AREA=IT-Software, COMPANYNAME=TCS, JOBLOC=Pune, SALARY=5000, CONTACT_NO=1238, EMAIL=n@tcs.com, WORK_EXP=4, SKILL_SET=Java, COMPANYLOC=Pune}, {STATUS=Open, FUNCTIONAL_AREA=IT Software, COMPANYNAME=tcs, JOBLOC=pune, SALARY=4000, CONTACT_NO=12345, EMAIL=np@gmail.com, WORK_EXP=7, SKILL_SET=Java,J2EE, COMPANYLOC=pune}, {STATUS=open, FUNCTIONAL_AREA=IT-Software, COMPANYNAME=TCS, JOBLOC=Pune, SALARY=5000, CONTACT_NO=1238, EMAIL=p@tcs.com, WORK_EXP=4, SKILL_SET=Java, COMPANYLOC=Pune}]

Can anybody tell me How to extract values from this output and show it in table format?
 
Sheriff
Posts: 67651
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Neha Deshmukh wrote:I am developing an application in which I am sending a ResultSet from servlet to jsp page.


Bad, bad, bad practice.

Rather, extract the data from the resultset immediately and store it in a Java collection. Resultsets should never get anywhere near a JSP (or a servlet for that matter -- it should be handled in the Model layer).

Once on the JSP, the JSTL and EL can be used to easily traverse the Java collection. You should never have Java code on a JSP -- that's a practice that has been discredited for over 8 years now.
 
Bear Bibeault
Sheriff
Posts: 67651
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You say:

Neha Deshmukh wrote:In servlet the output of query is stored in ArrayList and I am sending this ArrayList using <jsp:forward page > tag.


and then you say:

In my jsp page I am getting ResultSet result using request.getParameter("param1").


This is very confusing. If you already have the data in a List, and you are "sending" (what do you mean by that?) to the JSP, how are you getting a resultset on the JSP, and why are you using getParameter()?

You also say that you are using <jsp:forward> in a servlet, and of course, you cannot possibly be.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic