Results 1 to 4 of 4
  1. #1
    Join Date
    May 2002
    Posts
    4

    Unanswered: JavaServer question

    I am using JSP 1.0.1 and I need function to convert:

    1. String to Double
    2. Double to String

    Please post your replies ASAP.

  2. #2
    Join Date
    May 2002
    Location
    Bergen, Norway
    Posts
    2
    Double to String: String.valueOf(double)

    String to double: Double.parseDouble(String s)

  3. #3
    Join Date
    May 2002
    Posts
    4

    Smile

    Thanks.
    Can you explain with an example.

  4. #4
    Join Date
    May 2002
    Location
    Bergen, Norway
    Posts
    2
    Say you have a bean called MyBeanwith with a field f1 ( a double)
    In your jsp page:
    <jsp:useBean id="bean_instance" scope="session" class="com.package.MyBean" />

    Parsing an incoming parameter to a double:

    <%
    String double_str=request.getParameter("double_val");
    double dbl = Double.parseDouble(double_str);
    %>

    <jsp:setProperty name="bean_instance" property="f1" value="<%=dbl%>" />

    The other way round :

    <%
    String parsed_double=String.valueOf(dbl);
    %>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •