• Post Reply Bookmark Topic Watch Topic
  • New Topic

Read String from Servlet

 
jordan ryan
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to work out how to get a string from a servlet in to the JSP, The code I thought would work was as follows.



This is returning null any help or a link for a few examples would be great. I have tried a few examples and followed a few tutorials but I keep getting null or nullpointexceptions. Any help would be great.
 
K. Tsang
Bartender
Posts: 3609
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the "session" attribute enabled in the jsp?

Why is the request dispatcher pointing to a local file?
 
jordan ryan
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:Is the "session" attribute enabled in the jsp?

Why is the request dispatcher pointing to a local file?


I dont think I have enabled the attribute in JSP and i'm doing this locally and this was just an example of where the JSP file was, is this wrong to have this as the JSP location?

As you will see my codes quite messy at the moment But I want to get the functionality working and then tidy it all up, the final bit im trying to do is read values from a XML and display these on the JSP. So I'm trying to work out how to send information from the servlet to JSP. I'm not sure if im on the right track at what im looking at or if im looking in completely the wrong place. But at the moment the JSP is not getting anything.

This is my actuall code so far.


 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your should be using the EL and JSTL in the JSP, not obsolete scriptlets.

In which case, the reference tot he variable would simply be ${test}
 
jordan ryan
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Your should be using the EL and JSTL in the JSP, not obsolete scriptlets.

In which case, the reference tot he variable would simply be ${test}


Thanks :) I Have it working now but I'm not sure if I did what you meant. This is the code I used is this best practise? I used JSTL like you said I was looking at it but took me a while to understand.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!