473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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

Similar topics

1
by: Hai Tran | last post by:
Any help is appreciated. Installed Tomcat 4.1 and Mysql on a WinXP. I've manage to get Tomcat up and was able to view my first application ( myhome ) simple home page. Tomcat was installed under...
1
by: efiedler | last post by:
Hi - I have the following input field on my html page: <input type="image" name="submit" id="submit" src="c:\image.jpg" value="image.jpg"> I also have another input field on the form that is...
3
by: rajarya | last post by:
Hi, I m designing a HTML page(index.html),here i have 2 frames,by defult both frames have index1.html and index2.html as their source . in first frame(index.html) ,i have some redio buttons,and a...
2
by: zoeabraham | last post by:
I am Using STRUTS1.4 in NetBeans5.5 IDE Here we have a JSP Page <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"...
1
by: shiyamala | last post by:
Hi i am shiyam, i am having some problem in java, i am basic java programmer. i have to write one program is writing the data into textfile name "newfile.txt" from one servlet and read it from...
2
by: wreed06 | last post by:
Hello, I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully...
3
by: vijaykumardahiya | last post by:
Hello To Every One, I want to know that when I upload the File like a image from html page Its not show on servlet page using appropriate logic. I read the FileUpload Home page.But I am still...
2
by: sumanta123 | last post by:
Dear Sir, In my develpment i am getting stuck for a senario.Kindly please help me for it. Everytime we give the request we get the response of 8 records and its corresponding value. Then next...
1
by: jeddiki | last post by:
Hello, I have made a nice opt-in form and tested it in Moz FF and it looks fine. But in IE the elements don't line up properly. I think I am nearly there but can not get these elements...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.