- A JSP that outputs an HTML form to browser, then when one of the buttons is clicked after user enters an amount in the
- 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
description The server encountered an internal error () that prevented it from fulfilling this request.
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
You shouldn't be using scriptlets in JSPs, that has been obsolete for a long time. EL (expression language) and JSTL are used for that nowadays. See https://coderanch.com/wiki/660053/Jsp-Faq for more on this subject, particularly the 4-part introduction to EL and JSTL under "Resources".
posted 1 year ago
Tim, thank you for the reply.
I have indeed gathered that scriptlets have been obsolete for a long time, however for my task I need to follow the textbook's instructions - yes it is an old book.
I will review the suggested for my own knowledge, but could you still let me know how I can achieve the asked using scriptlets in the JSP?