• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Read String from Servlet

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic