• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object to String in JSP

 
Macario Garcia
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Prafulla N. Patil
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!