Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Variables from classes

 
Pan Niko
Ranch Hand
Posts: 86
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Anyone knows what i have to do to can put a variable from class in jsp variable?

My page working fine until know but just print out the class' variable in <td> tag. When im tring to put String text = package.name; i have exception.

package.name cannot be resolved to a type
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, you shouldn't be putting Java code into a JSP in the first place. That's an outdated and discredited practice that should have ended almost 10 years ago.

Time to update your JSP knowledge.

Secondly, without seeing more code, I'm not anyone can help.
 
Pan Niko
Ranch Hand
Posts: 86
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed my code now an is ok, didn't store classes variable in jsp. My problem now is that trying to getAttribute() but i want to convert it in integer.



Tried this but i have exception at that line.
any idea?
thank you
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IS this in the JSP or the servlet? And telling us you are getting an exception without showing us the exception is not helpful.
 
Pan Niko
Ranch Hand
Posts: 86
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is a jsp and page just saying

An exception occurred processing JSP page at the line posted before
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As always, I advise moving any Java code out of the the JSP -- it doesn't belong there.

But there is more to the exception than you are posting. Perhaps in the logs or on the console. We can't help with what you've shown so far.
 
Pan Niko
Ranch Hand
Posts: 86
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Here is the full page
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well:
says it all, doesn't it?
 
Pan Niko
Ranch Hand
Posts: 86
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the first year where im doing html,xml,jsp etc.. so forgive me.

The error is because 1.56 is not an nteger but a float?
 
Paul Clapham
Sheriff
Posts: 21319
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Panayiotis Niko wrote:Is the first year where im doing html,xml,jsp etc.. so forgive me.

But this is nothing to do with any of those... it's a Java problem.
The error is because 1.56 is not an nteger but a float?

From the API documentation for Integer.parseInt...
The documentation wrote:Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits...

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic