3

I am fairly new to JSP , i learned that to create a variable you say this

<%String abc="1"; %>

If i want to change to value of abc I used this

<%= abc = "2" %> //Is this the right way??

But this value is shown on my JSP page how do I make it not show in my jsp page.

kal
  • 28,545
  • 49
  • 129
  • 149
  • I encourage you to read [this](http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files). – BalusC Dec 01 '10 at 03:58

3 Answers3

4

The short answer to your question is remove the =. The <%= %> evaluates and prints the contents. Anything between <% %> is just standard java code. So, you want

<% String abc = "1"; %>
....some stuff....
<% abc = "2"; %>
Chris Thompson
  • 35,167
  • 12
  • 80
  • 109
3

Change

<%= abc = "2"; %> 

To

<% abc = "2"; %>

Delete the "="

Enrique
  • 9,920
  • 7
  • 47
  • 59
0

A JSP expression is used to insert Java values directly into the output. It has the following form:

 &lt;%= Java Expression %&gt;

refer: http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/Servlet-Tutorial-JSP.html

Using only one = operator to change value of abc. http://faculty.cs.wwu.edu/meehan/Programming_Language_Projects/JSP/

user2427906
  • 321
  • 2
  • 5