Meaningless Drivel is fun!*
The moose likes JSP and the fly likes Variables from classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Variables from classes" Watch "Variables from classes" New topic
Author

Variables from classes

Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

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

Joined: Jan 10, 2002
Posts: 61180
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

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

Joined: Jan 10, 2002
Posts: 61180
    
  66

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

Joined: Mar 19, 2011
Posts: 86

is a jsp and page just saying

An exception occurred processing JSP page at the line posted before
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

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

Joined: Mar 19, 2011
Posts: 86



Here is the full page
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61180
    
  66

Well:
says it all, doesn't it?
Pan Niko
Ranch Hand

Joined: Mar 19, 2011
Posts: 86

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
Bartender

Joined: Oct 14, 2005
Posts: 18563
    
    8

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...

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Variables from classes