Sourav Mehra
Sourav Mehra

Reputation: 445

JSP equal symbol expected

I have the following code:

<html:submit onclick="saveuc(<%=request.getAttribute("userId") %>,<%=request.getAttribute("domainName")%>,<%=request.getAttribute("applicationName")%>,<%=request.getAttribute("domainId")%>)">Save</html:submit>

Can anyone help what is the error in syntax here?

I get the below exception

Servlet.service() for servlet action threw exception: javax.servlet.jsp.JspException: ServletException in '/common-layout.jsp': ServletException in 'pages/UseCaseScreen.jsp': /pages/UseCaseScreen.jsp(62,82) equal symbol expected

Upvotes: 0

Views: 684

Answers (1)

dsp_user
dsp_user

Reputation: 2119

Probably the simplest way to resolve that issue is to use EL (expression language). So just replace your existing code with

<html:submit onclick="saveuc(${userId},${domainName},${applicationName},${domainId})">Save</html:submit>

EL (at least in this case) uses an implicit object (requestScope) so you could also write

 <html:submit onclick="saveuc(${requestScope.userId},${requestScope.domainName},${requestScope.applicationName},${requestScope.domainId})">Save</html:submit>

Upvotes: 1

Related Questions