0
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 176 in the jsp file: /encrypted.jsp
gn cannot be resolved

173:     <input type="text" name="itt"  value=""  />
174:         </label><br><br><br><br>
175:            <label><b>Generated Key-</b>
176:             <input type="text" name="Gnkey" value="<%=gn%>"/>
177:         </label>
178:  </td>

the gn variable is used to store a output from a function

<%
String gn = generateKey(SelectedIndex, key, itt);
%>

how to resolve this error?

Sandeep Chatterjee
  • 3,220
  • 9
  • 31
  • 47
Nit kt
  • 95
  • 2
  • 3
  • 8

1 Answers1

0

Put it in pageContext

<%
  pageContext.setAttribute("gn", gn);
%>

and then access it like ${gn}

or

change

<%
String gn = generateKey(SelectedIndex, key, itt);
%>

to

<!%
String gn = generateKey(SelectedIndex, key, itt);
%>

Also See

Community
  • 1
  • 1
jmj
  • 237,923
  • 42
  • 401
  • 438
  • error in writing `pageContext.setAttribute("gn", gn);` showing, cannot find the symbol gn. – Nit kt Mar 27 '14 at 02:20
  • you do it in the same scope as `String gn = generateKey(SelectedIndex, key, itt);` – jmj Mar 27 '14 at 02:20
  • not working this. but first decelerating String gn in `<%! String gn; %>` helped. now recognized at every place i used. – Nit kt Mar 27 '14 at 02:27