Good day, all.
I have the following setup:
- A
JSP that outputs an HTML form to browser, then when one of the buttons is clicked after user enters an amount in the
text field,
- The data is sent to a
servlet that performs certain calculations and sends result data back to the JSP.
- The JSP then shows the result data and keeps running so user can make more iterations using the program.
I am trying to code the JSP such that when it runs, it first checks for existence of 2 session attributes, "balance"
and "formattedBal". If these attributes do not exist (meaning this is the very first time running the JSP after the
user just hit its URL address), the JSP execution must create and assign these session attributes. If these attributes
do exist (meaning this was not the initial launch of the JSP but a consequent one, with servlet having reverted the user
to the JSP and sent result data, hence non-null session attributes to it), the JSP must simply execute the HTML output,
showing the values of said session attributes in appropriate coded places.
The following is the code of the JSP:
The problem is, I'm getting an error that points to line 11 - the <% tag. Whether I use a function or not, the error
remains and reads exactly as follows:
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 occured at line: 11 in the jsp file: /bank.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:397)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I have been researching this and related errors, but to not much avail.
What makes no sense is the error states that I am using an = sign, but it expects an != combination, while as you see
line pointed to there is never an = sign in the first place.
I'm new to
Java and it is possible this is a simple mistake somewhere, could you please help to identify it?
I need to use scriptlets in the JSP whenever I need to utilize "standard" Java commands.
Also, if the described and coded way to check for existence of these session attributes and their conditional
assigning is not correct, please advise how I would better achieve this.
Thank you very much!