• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
radha mali
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
radha mali
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please see my most recent reply -- and please use code tags when posting code.
 
radha mali
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64720
86
IntelliJ IDE Java jQuery Mac Mac OS X
 
Jessid Leon Velez Gutierrez
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic