469,282 Members | 2,320 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Display value of float from servlet to jsp page.

283 100+
Hi friends,
The situation is, in my class i have certain float parameters like--->
Expand|Select|Wrap|Line Numbers
  1. Double double1 = new Double(s18);
  2.             float f3 = double1.floatValue();
and s18 is--> s18 = resultset.getString("Budget_Alloted");
and so on...
and in my jsp page i want to display the value of f3
for ex-->[HTML]BUDGET ALLOTED : <b>" + f3 + "</b><br>[/HTML] . How can i do that. Any help will be appreciated.
regards,
ajos
Nov 19 '07 #1
11 7041
r035198x
13,262 8TB
Hi friends,
The situation is, in my class i have certain float parameters like--->
Expand|Select|Wrap|Line Numbers
  1. Double double1 = new Double(s18);
  2.             float f3 = double1.floatValue();
and s18 is--> s18 = resultset.getString("Budget_Alloted");
and so on...
and in my jsp page i want to display the value of f3
for ex-->[HTML]BUDGET ALLOTED : <b>" + f3 + "</b><br>[/HTML] . How can i do that. Any help will be appreciated.
regards,
ajos
Expand|Select|Wrap|Line Numbers
  1.  <%=f3%>

Also have a google at Java's naming and code conventions. I'm sure you'll find them instructive.
Nov 19 '07 #2
ajos
283 100+
Expand|Select|Wrap|Line Numbers
  1.  <%=f3%>

Also have a google at Java's naming and code conventions. I'm sure you'll find them instructive.
Thanks for the response...thats what we do to display the value....But my problem is how to bring the value of float f3 to be displayed in a jsp page....for example...for a property in a form viz username to be dispayed we write something like this is form bean--->
Expand|Select|Wrap|Line Numbers
  1. setUsername(String username)
  2. and getUsername();
  3.  
and in jsp page we do something like
Expand|Select|Wrap|Line Numbers
  1. formbean.getParameter("username")
  2. <%=username%>
  3.  
something like this. I hope you got my point.
Nov 19 '07 #3
r035198x
13,262 8TB
Thanks for the response...thats what we do to display the value....But my problem is how to bring the value of float f3 to be displayed in a jsp page....for example...for a property in a form viz username to be dispayed we write something like this is form bean--->
Expand|Select|Wrap|Line Numbers
  1. setUsername(String username)
  2. and getUsername();
  3.  
and in jsp page we do something like
Expand|Select|Wrap|Line Numbers
  1. formbean.getParameter("username")
  2. <%=username%>
  3.  
something like this. I hope you got my point.
Sorry I don't get your point ...
The float f3 will be displayed on the JSP page if you put the code I posted above in the JSP.
Nov 19 '07 #4
ajos
283 100+
Sorry I don't get your point ...
The float f3 will be displayed on the JSP page if you put the code I posted above in the JSP.
Ok. by writing <%=f3%> i can display the value. But the code
Expand|Select|Wrap|Line Numbers
  1. Double double1 = new Double(s18);
  2. float f3 = double1.floatValue();
  3.  
is in my servlet class. How do i set and get here in order to display it in my jsp page. Hope you get me this time:)
Nov 19 '07 #5
r035198x
13,262 8TB
Ok. by writing <%=f3%> i can display the value. But the code
Expand|Select|Wrap|Line Numbers
  1. Double double1 = new Double(s18);
  2. float f3 = double1.floatValue();
  3.  
is in my servlet class. How do i set and get here in order to display it in my jsp page. Hope you get me this time:)
You have to pass the value to the JSP then using request.setAttribute or the session attribute.
Nov 19 '07 #6
ajos
283 100+
You have to pass the value to the JSP then using request.setAttribute or the session attribute.
Ive done something like this in my servlet--->
Expand|Select|Wrap|Line Numbers
  1. Double double1 = new Double(s18);
  2.             float f3 = double1.floatValue();
  3.             httpservletrequest.setAttribute("f3", f3);
is this way right?
now how do i retrieve the value in jsp page?
Nov 19 '07 #7
r035198x
13,262 8TB
Ive done something like this in my servlet--->
Expand|Select|Wrap|Line Numbers
  1. Double double1 = new Double(s18);
  2.             float f3 = double1.floatValue();
  3.             httpservletrequest.setAttribute("f3", f3);
is this way right?
now how do i retrieve the value in jsp page?
Expand|Select|Wrap|Line Numbers
  1. request.setAttribute("name", value);
Then in the JSP you use
Expand|Select|Wrap|Line Numbers
  1. request.getAttribute("name");
Nov 19 '07 #8
ajos
283 100+
Expand|Select|Wrap|Line Numbers
  1. request.setAttribute("name", value);
Then in the JSP you use
Expand|Select|Wrap|Line Numbers
  1. request.getAttribute("name");
I did something like this
Expand|Select|Wrap|Line Numbers
  1. <%request.getAttribute("f3"); %>
  2. BUDGET ALLOTED : <b> <%=f3 %> </b><br>
  3.  
I think its wrong coz f3 is not recognized here.Or am i doing something wrong here?
Nov 19 '07 #9
r035198x
13,262 8TB
I did something like this
Expand|Select|Wrap|Line Numbers
  1. <%request.getAttribute("f3"); %>
  2. BUDGET ALLOTED : <b> <%=f3 %> </b><br>
  3.  
I think its wrong coz f3 is not recognized here.Or am i doing something wrong here?
Of course it's not.
You need to declare it with something perhaps like

Expand|Select|Wrap|Line Numbers
  1. String f3 = request.getAttribute("f3");
P.S Please do not ignore my earlier comment about having a look at code conventions.
Nov 19 '07 #10
ajos
283 100+
Of course it's not.
You need to declare it with something perhaps like

Expand|Select|Wrap|Line Numbers
  1. String f3 = request.getAttribute("f3");
P.S Please do not ignore my earlier comment about having a look at code conventions.
Ok. I did as you said but we cannot convert from object to float.
like
Expand|Select|Wrap|Line Numbers
  1. <%float f3=request.getAttribute("f3"); %>
  2. BUDGET ALLOTED : <b> <%=f3 %> </b><br>
I had tried this way earlier too. As for the naming conventions goes, this project is not done by me, ive told to make certain modifications in them, so i cant really change what the original developer has done, but i agree with you the naming conventions are horrible.
Nov 19 '07 #11
r035198x
13,262 8TB
Ok. I did as you said but we cannot convert from object to float.
like
Expand|Select|Wrap|Line Numbers
  1. <%float f3=request.getAttribute("f3"); %>
  2. BUDGET ALLOTED : <b> <%=f3 %> </b><br>
I had tried this way earlier too. As for the naming conventions goes, this project is not done by me, ive told to make certain modifications in them, so i cant really change what the original developer has done, but i agree with you the naming conventions are horrible.
request.getAttribute returns an object. You have to cast it to the type that you want.
Nov 19 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Hai Tran | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.