• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Integer vs. String

 
Marko Debac
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
addition:

when I input String on same whay its ok:


but on number, everything colapse

regardes,
Marko
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Marko Debac
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ment this that I have for printing out
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because it didnt work ,
so I ment that I am loosing track

Marko
 
Marko Debac
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tryed this to, end nothing
 
Marko Debac
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


end this
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Integer.parseInt returns an int so there is no need for the cast.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what I get with



 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but here I have itand immidietly after this I have

It is wery odd
 
Marko Debac
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic