This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Read String from Servlet

 
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.
 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • 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.


 
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!