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:

Code:
<html>
	<hr>		<!--Horizontal line.-->
	<title>Online Bank ATM Simulator</title>		<!--Title to show on browser title bar.-->
	<h1 align = "center">Bank ATM Simulation</h1>	<!--Page heading, centered on page.-->
	
	<SCRIPT LANGUAGE = JAVASCRIPT>
	<!--
	
	function checkAttributes()
	{
	<%
	// Set balance and formatted balance as session attributes.
	if(request.getSession().getAttribute("balance") = null && request.getSession().getAttribute("formattedBal") = null)
	{
		request.getSession().setAttribute("balance", 0);
		request.getSession().setAttribute("formattedBal", "$0");
	}
	%>
	}
	-->
	</SCRIPT>
	
	<body onLoad = "checkAttributes()", "amount.focus()">				<!--Set focus to the text-field.-->
		<form method = "POST" action = "../servlet/JSPBank">	<!--Form method and submission address.-->
			<center>		<!--Tag to center the following output on page.-->
			Amount: 
			<input type = "text" name = "amount" id = "amount" size = "20"><br><br>	<!--Amount text field.-->
			Balance: 
			<%=(String)request.getSession().getAttribute("formattedBal")%> + "<br><br>	<!--Current formatted balance shown.-->
			<button name = "balButton" value = "Balance">Balance</button>	<!--"Balance" button.-->
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	<!--Spacers.-->
			<button name = "depButton" value = "Deposit">Deposit</button>	<!--"Deposit" button.-->
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	<!--Spacers.-->
			<button name = "withdrButton" value = "Withdraw">Withdraw</button>	<!--"Withdraw" button.-->
			</center>		<!--Tag to end centering of output on page.-->
		</form>		<!--End of form.-->
	</body>
	<br>
	<hr>		<!--Horizontal line.-->
</html>
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!