wood burning stoves 2.0*
The moose likes JSP and the fly likes Integer vs. String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Integer vs. String" Watch "Integer vs. String" New topic
Author

Integer vs. String

Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121
Hi,
I have a problem with displaying a number which I has inserted through HTML input



Does somebody know why or how?

regardes,
Marko
Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121
addition:

when I input String on same whay its ok:


but on number, everything colapse

regardes,
Marko
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61202
    
  66

I'm really confused as to what you are trying to accomplish.

Firstly, you are mixing JSTL, EL and scriptlets? Why the scriplets?

Secondly, you are trying to obtain request params in the same page as defines the form. In this case, the form hasn't even been displayed yet, so how can it have been submitted in order to generate the request params?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121
Hi Bear,
I am doing some web services, and I am calling operation within jsp, and I passing her a input var, and proceding output of operation on the next page.jsp, so it is a problem - I must mix

But this is very little mixing , and it must be done.



when I pass the String, it is ok

but when I need to pass int
but before
<%....%>
I have
so, I need to put those values into <%....%>, but String it accept, and on int, it colapse

And I cant get it,
please help,
regardes,
Marko
Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121
I ment this that I have for printing out
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61202
    
  66



The getParameter() method returns a String. Always.

Is this the way that you'd convert a string into an int in a Java program? Of course not. You can't cast a String to an int.

In an earlier code snippet you used Integer.parseInt(). Why did you stop using that?
Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121
because it didnt work ,
so I ment that I am loosing track

Marko
Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121
I tryed this to, end nothing
Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121


end this
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410



Integer.parseInt returns an int so there is no need for the cast.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61202
    
  66

it didnt work


These are the three most useless words you could post on this forum. How did it not work?
Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121
This is what I get with



Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

org.apache.jasper.JasperException: java.lang.NumberFormatException: null



This is the exception that will be thrown if you try to convert a null to an int.
This means that no "id_user" parameter was sent to your page.
Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121
but here I have itand immidietly after this I have

It is wery odd
Marko Debac
Ranch Hand

Joined: Aug 21, 2006
Posts: 121
I have figure out:
I will pass String parameter in web service operation, but on the server side I will do parsing before entering the database.

Thank you guys on the thinking with me,
Regardes,
Marko
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Integer vs. String