Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 32

Thread: Would like to use a script to input Math functions...

  1. #11
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Right! I just had it in the wrong folder!

    I did it, and got this:

    Code:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    
    An error occurred at line: 5 in the jsp file: /Hello.jsp
    Generated servlet error:
    Syntax error on token "(", ; expected
    
    An error occurred at line: 5 in the jsp file: /Hello.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /Hello.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /Hello.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /Hello.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /Hello.jsp
    Generated servlet error:
    Syntax error on token ")", delete this token
    line 5:

    Code:
    <%// ability_calculator.jsp
       double CalculateAbility( double effortValue, double baseValue,
            double individualValue, double level, double personality );
       {
            double quarterEffort = Math.Floor( effortValue / 4 );
            double doubleBase = baseValue * 2;
            double levelValue = 
                    ( doubleBase + individualValue + quarterEffort ) * level;
            double levelPercentage = levelValue / 100;
            double personalityValue = 
                    Math.Floor( ( levelPercentage + 5 ) * personality );
    
            return personalityValue;
       }
    %>

    Ideas?

    (p.s. Thanks a ton for your time on this Twey!)
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  2. #12
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Extraneous semicolon after the function declaration.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #13
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    took it out, and got:

    Code:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    
    An error occurred at line: 5 in the jsp file: /Hello.jsp
    Generated servlet error:
    Syntax error on token "(", ; expected
    
    An error occurred at line: 5 in the jsp file: /Hello.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /Hello.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /Hello.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /Hello.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /Hello.jsp
    Generated servlet error:
    Syntax error on token ")", ; expected
    **sigh** I am screwing up somewhere.... it all started when I woke up one day....
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #14
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    The following compiled here (although I didn't execute it) {
    Code:
       double CalculateAbility( double effortValue, double baseValue,
            double individualValue, double level, double personality )
       {
            double quarterEffort = Math.floor( effortValue / 4 );
            double doubleBase = baseValue * 2;
            double levelValue =
                    ( doubleBase + individualValue + quarterEffort ) * level;
            double levelPercentage = levelValue / 100;
            double personalityValue =
                    Math.floor( ( levelPercentage + 5 ) * personality );
    
            return personalityValue;
       }
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #15
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Is it just me?

    I mean, sure I know how to read, and I followed the tut, got it running, tested with 4 different test scripts, all worked.

    I put this one in, and get these error codes.

    Just to be sure here is the full jsp page:

    ability_calculator.jsp:
    Code:
    <HTML>
    <HEAD>
    <TITLE>Ability Calculator</TITLE></HEAD>
    <BODY BGCOLOR="#FDF5E6">
     <%
     double CalculateAbility( double effortValue, double baseValue,
            double individualValue, double level, double personality )
       {
            double quarterEffort = Math.floor( effortValue / 4 );
            double doubleBase = baseValue * 2;
            double levelValue =
                    ( doubleBase + individualValue + quarterEffort ) * level;
            double levelPercentage = levelValue / 100;
            double personalityValue =
                    Math.floor( ( levelPercentage + 5 ) * personality );
    
            return personalityValue;
       }
       %>
    Personality value for values given:  <%= CalculateAbility(
      Double.parseDouble(request.getParameter("eff")),
      Double.parseDouble(request.getParameter("bas")),
      Double.parseDouble(request.getParameter("ind")),
      Double.parseDouble(request.getParameter("lev")),
      Double.parseDouble(request.getParameter("per"))
    ) %>
    </BODY>
    </HTML>
    as well as the FULL error output from the local server:

    Code:
    HTTP Status 500 -
    
    type Exception report
    
    message
    
    description The server encountered an internal error () that prevented it from fulfilling this request.
    
    exception
    
    org.apache.jasper.JasperException: Unable to compile class for JSP
    
    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token "(", ; expected
    
    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token ")", ; expected
    
    
    	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    
    root cause
    
    org.apache.jasper.JasperException: Unable to compile class for JSP
    
    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token "(", ; expected
    
    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token ",", ; expected
    
    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token ")", ; expected
    
    
    	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
    	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
    	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
    	org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
    	org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
    	org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
    	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
    Apache Tomcat/5.5.17
    It's something simple isn't it? It always is... some stupid little space or carriage return or some thing...

    BTW, just so I understand.. the error lines, say this one:

    An error occurred at line: 5 in the jsp file: /ability_calculator.jsp
    Generated servlet error:
    Syntax error on token "(", ; expected

    This is saying there is a syntax error in line 5 of the jsp page, and that it detects the ( symbol, and is expecting a ;

    right?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #16
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Hahahahaha.
    Oh dear, I made a really stupid mistake.

    Functions can't be defined within scriptlets; you need to use a declaration. Add ! to the end of the opening tag for the scriptlet in which the function is defined.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #17
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    okay if I understood correctly, I did this:

    Code:
     <%!
     double CalculateAbility( double effortValue, double baseValue,
            double individualValue, double level, double personality )
       {
            double quarterEffort = Math.floor( effortValue / 4 );
            double doubleBase = baseValue * 2;
            double levelValue =
                    ( doubleBase + individualValue + quarterEffort ) * level;
            double levelPercentage = levelValue / 100;
            double personalityValue =
                    Math.floor( ( levelPercentage + 5 ) * personality );
    
            return personalityValue;
       }%>
    Adding the ! after the first %

    Now, the errors are gone, but I get this:

    Code:
    org.apache.jasper.JasperException: Exception in JSP: /ability_calculator.jsp:21
    
    18:    }%>
    19: Personality value for values given:
    20: <%=CalculateAbility(
    21:   Double.parseDouble(request.getParameter("eff")),
    22:   Double.parseDouble(request.getParameter("bas")),
    23:   Double.parseDouble(request.getParameter("ind")),
    24:   Double.parseDouble(request.getParameter("lev")),
    
    
    Stacktrace:
    	org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
    	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
    	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    So I am guessing that brings me back to your comment about passing the "eff" "per" etc using POST or GET... but where?

    Do I do it like in php and at the top say eff=30 or something?
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  8. #18
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Yep, you can do that, or you can write a form.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #19
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    A form is what I want though right? So I can enter the different variable each time, without having to change the jsp page??

    So would I make an html page with text boxes for the variables and then a submit button that will call the jsp page?

    **Runs to look at the tut link from before**
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  10. #20
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    So would I make an html page with text boxes for the variables and then a submit button that will call the jsp page?
    Ayup. You could just change the GET variables in the address bar, though, like you suggested before.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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