wood burning stoves 2.0*
The moose likes JSP and the fly likes Resultset elements not getting displayed in jsp when using JSP/JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Resultset elements not getting displayed in jsp when using JSP/JSTL" Watch "Resultset elements not getting displayed in jsp when using JSP/JSTL" New topic
Author

Resultset elements not getting displayed in jsp when using JSP/JSTL

radha mali
Greenhorn

Joined: Apr 01, 2011
Posts: 9
Hi

I want to show the values i obtain from database in a jsp file. I am using JSTL to iterate the collection. I have the java bean defined with getter and setter methods. I am using request.setAttribute("rows", rows) and i iterate over the items in my jsp. But i cannot see any values and the page is blank.

my code..

please advise me.


redirect will take to resultspage

my jps file


i have a java bean which has getName and getSalary methods

please help.

thank you
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

Never, ever, ever, ever, and did I mention ever, send a resultset to a JSP.

Copy the data out of the resultset into a Java collection of some type, and close the resultset, releasing its resource, as soon as possible.

Then send the data collection on to the JSP.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
radha mali
Greenhorn

Joined: Apr 01, 2011
Posts: 9
thanks for reply bear. I am not sending resultset to jsp.i created an arraylist with the employee data and setting that as an attribute in request. like request.setAttribute("rows", rows)
i am assuming this list is what is used by foreach items attribute. but i cant even debug what going on as i am a newbie to jstl.

if i am not clear please excuse.

why do i see blank page..it seems like control doesnot go in to foreach..so i think the collection is not visible?

struggling with this issue for hrs now.please help

thank you
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

OK, I did not read your code because it was unformatted. I went ahead and fixed that by adding code tags. See how much better that is!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

"The page is blank". Please elaborate. Does that mean that no HTML at all is being returned? (Use View Source). Or that no data is being displayed in your HTML?
radha mali
Greenhorn

Joined: Apr 01, 2011
Posts: 9
thank you. what is the problem with my code? am i missing configuration. i put a breakpoint in getter and i cannot hit that point as it does not go in side foreach loop.
radha mali
Greenhorn

Joined: Apr 01, 2011
Posts: 9
the page is blank ..i meant there is no content. i already clicked view source and i do not see anything other than html tags no data between table tags..

sorry i did not mention before
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

OH, <slaps forehead>.

Use a forward rather than a redirect.

A redirect causes a new request to be issued, and so your scoped variable is lost.
radha mali
Greenhorn

Joined: Apr 01, 2011
Posts: 9
this is how it looked now..


<html>
<head>
<title>Log In Page</title>
<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />


</head>

<body>
<table>






</table>
</body>
</html>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

Please see my most recent reply -- and please use code tags when posting code.
radha mali
Greenhorn

Joined: Apr 01, 2011
Posts: 9
thanks bear. it worked perfectly. this one thing i did not try. i am new to this forum and did not know how to use code tags. i will learn them.thanks again for your help
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

Jessid Leon Velez Gutierrez
Ranch Hand

Joined: Jan 19, 2011
Posts: 35
Bear Bibeault wrote:OH, <slaps forehead>.

Use a forward rather than a redirect.

A redirect causes a new request to be issued, and so your scoped variable is lost.


Bear thanks for this answer. I havent thouht of that before. I will have it in mind when i find troubles like this....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Resultset elements not getting displayed in jsp when using JSP/JSTL
 
Similar Threads
Using Two ArrayLists For One Table
How can I set a form name in a jsp page using <html:form> tag ?
struts 2 design problem
JSP column name hyperlink help
how to print values on jsp page fetched from servlet