• 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

JSP not picking up getAttribute from Servlet

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

I've been posting my problems here and I am glad it was answered.

I have another assignment. I am halway there, but the last bit is not working.

I have a servlet file which the code looks like this:



When I query, the result came out successfully in the command prompt (where the tomcat server started up and displayed) but in the viewSearch.jsp, there is no result displayed.

My viewSearch.jsp looks like this:



What's wrong? Is it because of my configuration of web.xml or these codes?

Thanks in advance for helping me.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check the log file to see if some exception has occured

 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i dont know what is your requirement to display. i dont see any logic (setting values into List and Iterating it in jsp) in your code. Personally i recommend to use TO(Transfer Object)
 
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code look fine.

What exactly happens when you hit the link to reach the 'Search' class. I mean do you get the viewSearch.jsp page displayed in the browser with the message No Record or do you end up seeing a blank page or some thing else?
 
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi,

we didn't get what's your code logic.

you are trying to add al ArrayList just because color your line.

But i think that will done your only with ArrayList emp_list just iterate your list with status and according to odd or even put your color.

No need to do this complex logic.

 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

thanks for replying. Maybe I didn't clearly explain my program. I have three files:
1)search.jsp (to enter search criteria),
2)search.java, (to connect to DB and query the DB) and
3)viewSearch.jsp (to display the search result).

When I enter a search criteria at search.jsp, it goes to search.java to find the
record in the database. I can see the search result in the command prompt
but in the viewSearch.jsp, stated "No Record Found" (I can see the table and all).

I can explain more if this is not enough. Really need some lights shed here.

Thanks in advance.

 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Karthick,
I see the logfile and no exception occured.

Hi Nishan,
I don't really understand what are your explanation. Please share with me your ideas
 
Nishan Patel
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Hi Emma Aziz,

What i mean first of all you are using scriplet into your jsp page....which is not good for coding....

So, i mean use JSTL <c:forEach tag which gives you iterate your list so no need to write java code and iterate.

That JSTL tag provide you status attribute which gives you odd and even row status what you want. But you use it using division operation and find it is odd or even that gives JSTL. just put your color according to status attribute.

That's what i mean.







>
 
Saifuddin Merchant
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Emma Aziz - For all the design suggestions that you have got - your code is still correct the way it is. You could try putting a few System.out.println() statements in your JSP to find out how the flow is happening - that would give you some idea of whats going wrong...

Yes I agree with everyone out here that there are lot of design improvements that could be made to the code - it still does not answer the question why the current code is not working? Any thought on that?
 
Ranch Foreman
Posts: 275
jQuery Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried this :


and got no messages on server console !!
i think the scriplets aren't working ... m looking into why
 
Saifuddin Merchant
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aniruddh Joshi wrote:i tried this :


and got no messages on server console !!
i think the scriplets aren't working ... m looking into why



Your code is incorrect. Its going to throw a class cast exception at line 33 --> ArrayList empList = (ArrayList) itr.next();
That because the itr.next() is going to return the String 'Aniruddh' which is the first element in the ArrayList.

The problem with the original code is on similar lines. Here is the code that works..



Frankly - the code does need a lot of redesign - would have loved to help more but running short of time right now ...
 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,
I noticed that too. The scriptlets are not working. Anything under the tag <% %> are not working.

Anyone here knows how to solve this? Am really helpless here.

Thanks in advance
 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,
I noticed that too. The scriptlets are not working. Anything under the tag <% %> are not working.

Anyone here knows how to solve this? Am really helpless here.

Thanks in advance
 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,
I noticed that too. The scriptlets are not working. Anything under the tag <% %> are not working.

Anyone here knows how to solve this? Am really helpless here.

Thanks in advance
 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,
I noticed that too. The scriptlets are not working. Anything under the tag <% %> are not working.

Anyone here knows how to solve this? Am really helpless here.

Thanks in advance
 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes,
I noticed that too. The scriptlets are not working. Anything under the tag <% %> are not working.

Anyone here knows how to solve this? Am really helpless here.

Thanks in advance
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I see, you are using a List of Lists wherein you store employee information(like first name, last name etc) in a list and then add this list to another list which contains other such list of employee details.
And then in the JSP, you iterate over the main list and get its inner lists, each list containing employee details. The logic seems to be fine. Try putting log statements at various steps, or use a debugger and step through the code to figure out, what's going wrong.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Emma Aziz wrote:Yes,
I noticed that too. The scriptlets are not working. Anything under the tag <% %> are not working.



then you need to tell us in begining itself right? you are wasted everybody time here
 
Aniruddh Joshi
Ranch Foreman
Posts: 275
jQuery Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this works :



but m not clear about you alternate color scheme.. and of course this code could be written in a better way
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Aniruddh Joshi
I agree your code works but I think the original code is slightly different and uses list of lists and you are using only a single list for 1 employee.
 
Nishan Patel
Ranch Hand
Posts: 689
Scala Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi,

Just check your web.xml if you find any thing like


just remove ...

 
Aniruddh Joshi
Ranch Foreman
Posts: 275
jQuery Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Satya
I know it satya,
I have just rectified the mistake and left the further implentation for her
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Emma,

Did you solve this problem ? still scriptlets not working ?
 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Seetha,
I have just figured it out before Anirudh pointed it out

Hi Anirudh,
I've tried your codes and it is still, not working.

Hi Nishan,
There is no entry of that kind in my web.xml.

Hi Balu,
Yes, I have solved the problem. I removed and added again the Classpath in the Environment Variable, stop start service, and the problem, was solved.

I've tried putting some texts under the scriplets but anything didn't come out.

Thanks in advance.

 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Seetha,
I have just figured it out before Anirudh pointed it out

Hi Anirudh,
I've tried your codes and it is still, not working.

Hi Nishan,
There is no entry of that kind in my web.xml.

Hi Balu,
Yes, I have solved the problem. I removed and added again the Classpath in the Environment Variable, stop start service, and the problem, was solved.

I've tried putting some texts under the scriplets but anything didn't come out.

Thanks in advance.

 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Does anyone knows what is the solution? I've tried so many ways, the output are still the same.

Thanks.
 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All!

I am excited. I solved the problem. It is, surely, my web.xml configuration. Any scriplets under this application folder won't work, then I tried putting the jsp with a really simple scriptlets, is also not working. When I put them under other application folder, it worked.

So, I tried taking the other's web.xml, paste it under my application folder, and yes, the result is displayed.

I thanked all of you for helping me out of the block.

Thanks.
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Emma Aziz wrote:Hello All!

I am excited. I solved the problem. It is, surely, my web.xml configuration. Any scriplets under this application folder won't work, then I tried putting the jsp with a really simple scriptlets, is also not working. When I put them under other application folder, it worked.

So, I tried taking the other's web.xml, paste it under my application folder, and yes, the result is displayed.

I thanked all of you for helping me out of the block.

Thanks.



Hi Emma,

Did you really realize what is what is not working? Just copy pasting other xml can work but is better if you compare both to see what was going when it was not working, so the next time you will not lose time ;)
 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Albareto,

I will try to do that next time.

Thank you very much for the advice

 
Aniruddh Joshi
Ranch Foreman
Posts: 275
jQuery Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can even paste it now
 
Emma Aziz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

The web.xml which was not working is:



and the working one is:



I missed out something in the old web.xml.

Thanks
 
Skool. Stay in. Smartness. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic