Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting ResultSet String to ArrayList  RSS feed

 
Neha Deshmukh
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • 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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!