• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Object to String in JSP

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone, I have a question regarding with the .toString() function in JSP inside a Scriptlet.
It does not have any errors on Eclipse IDE but when I execute it it displays an error message.

Here is an example of my code:



And then when I run it on the server it will display:



I don't know what to do, I really need to convert the Objects into Strings so that I can use the Strings in Conditional Statements. Please help me, thank you very much!
 
Sheriff
Posts: 67620
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
For this to occur, student_number must be null.

Why exactly are doing all this conversion?

Aside from putting Java code in JSPs to begin with (rather a big no-no), there's usually very little need to do all this sort of stuff.
 
Macario Garcia
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:For this to occur, student_number must be null.

Why exactly are doing all this conversion?

Aside from putting Java code in JSPs to begin with (rather a big no-no), there's usually very little need to do all this sort of stuff.



Thank you very much! Thank you for mentioning the null thing, now I figured it out that it doesn't have any value because the Servlet didn't passed any data yet from my database.

Thank you again.

Case Solved. Out.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String s_student_number = (String)request.getAttribute("student_number_pass");

This should work for you without error and in one statement
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic