Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8324995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:16:46+00:00 2026-06-09T00:16:46+00:00

I am creating .jsp page and reiceve error about it ; String energyv=; int

  • 0

I am creating .jsp page and reiceve error about it ;

        String energyv="";

        int number= Integer.parseInt(request.getParameter("number"));
        energyv="_"+number;
    *
    *
    *
        if (tokenNumber == 2 && found && value1.equals("")) {
        value1= nextToken;
        if (value1.equals(""))
        found = false;

        }

        if (tokenNumber == 3 && found && value2.equals("")) {
        value2= nextToken;

        }

*
*
*
        Double activeTotalLong = Double.valueOf( "value" + energyv );

*
*
*

When try to do this I recieve tomcat error;

02 Aug 2012 11:17:30,097 ERROR http-8080-4
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/PlantVisorPRO].[jsp]
– Servlet.service() for servlet jsp threw exception java.lang.NumberFormatException: For input string: “value2” at
sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224)
at java.lang.Double.valueOf(Double.java:475)

Java can create my value ( like a value2 or value1), but how can i fix string problem ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:16:48+00:00Added an answer on June 9, 2026 at 12:16 am
    Double activeTotalLong = Double.valueOf( "value" + energyv );
    

    This method takes valid numbers represented in a string.

    “value2” isn’t a valid number format.

    Example usages of Double.valueOf():

    Double d;
    d = Double.valueOf("23.72");
    d = Double.valueOf("-1.247002");
    d = Double.valueOf("1e9"); // e  =    *10^()
    

    So, what you are trying to do is, get the value of value2 or value1. And what you actually wrote is

       "value" + 2
    =  "value2"    // This is a string! not a variable!
    

    So, to solve this, there are two options:

    • use arrays
    • use if-else

    Using arrays:

    String values[] = new String[2];
    values[0] = value1;
    values[1] = value2;
    Double.valueOf(values[energyv - 1]);
    

    Using if-else:

    Double activeTotalLong;
    if (energyv == 1)
    {
        activeTotalLong = Double.valueOf(value1);
    } else if (energyv == 2)
    {
        activeTotalLong = Double.valueOf(value2);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a JSP page, where i am dynamically creating a Table data.
I am creating one jsp page in which I read in a text file,
I am creating a project in struts2 I have created a Registration.jsp page like
I am creating a jsp page where a single news item is shown, just
I am creating a page in JSP where I have a dropdown list and
I am creating a JSP page, I get data from database this data is
I am creating a jsp page to test a validator servlet for a uni
<%@taglib uri=http://jakarta.apache.org/struts/tags-html prefix=html%> <%@taglib uri=http://jakarta.apache.org/struts/tags-bean prefix=bean %> I'm creating jsp file in eclipse it
what is the best way for creating a jsp visitor hit counters? is it
I am creating a simple application in JSP- JDBC for inserting and updating details

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.