aspose file tools*
The moose likes Beginning Java and the fly likes casting error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "casting error" Watch "casting error" New topic
Author

casting error

sagar khana
Greenhorn

Joined: Jan 15, 2012
Posts: 21
Hey everybody,
how are you?
i am having this casting problem i want to convert String s whose value is retrieved by a text field but i am getting this casting problem in:
"int i=(int)s;"

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

What is that Java code doing in a JSP?

At any rate, you've got this question about your Java code. So let's put the question into one of the Java forums. Moving...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Firstly, Java code in a JSP is a huge no-no! Please read this JspFaq entry.

Secondly, you cannot cast a String to an int. That's just basic Java.

As this isn't really about JSP at all, it's been moved to the Beginning Java forum.

[Edit: Paul beat me by 20 seconds!]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sagar khana
Greenhorn

Joined: Jan 15, 2012
Posts: 21
Bear Bibeault wrote:Firstly, Java code in a JSP is a huge no-no! Please read this JspFaq entry.

Secondly, you cannot cast a String to an int. That's just basic Java.

As this isn't really about JSP at all, it's been moved to the Beginning Java forum.

[Edit: Paul beat me by 20 seconds!]


hey ,

i am just trying to learn the concept to used scriplet and sorry to ask in this section thought it would be hoping to get the solution of my problem
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

No problem... it's just that your question has nothing to do with scriptlets. When you put Java code into a scriptlet, it's still Java code. Don't let the fact that it happens to be embedded in a JSP cloud your mind, it's still Java code. So questions about it are questions about Java code.

When you're programming, and especially when you're trying to fix problems, it's important to focus on the right things. Try to avoid being distracted by things which aren't relevant. I know, when you're a beginner it isn't always easy to tell what's relevant, so consider this moderator action to be part of your problem-solving process.
sagar khana
Greenhorn

Joined: Jan 15, 2012
Posts: 21
all i am trying is increasing my knowledge i used Integer.parseInt() function and problem solved thanks for your sharing
have a nice day :)

Paul Clapham wrote:No problem... it's just that your question has nothing to do with scriptlets. When you put Java code into a scriptlet, it's still Java code. Don't let the fact that it happens to be embedded in a JSP cloud your mind, it's still Java code. So questions about it are questions about Java code.

When you're programming, and especially when you're trying to fix problems, it's important to focus on the right things. Try to avoid being distracted by things which aren't relevant. I know, when you're a beginner it isn't always easy to tell what's relevant, so consider this moderator action to be part of your problem-solving process.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: casting error