1.11M Members

How to use java&jsp

 
0
 

Hi at all.
I'm a new user of jsp and I've a problem. I would execute certain operations every X seconds in my jsp project like check data into mySql DB; I use a TimerTask java class and it's ok. But if I would update the UI inside the run method, eclipse signs me an error ("Cannot refer to a non-final variable out inside an inner class defined in a different method"). The code is here:

<div style="text-align: right; font-size: 12px; padding-top: 400px;">
	<%!
	int i = 0;
	boolean refresh = false;%>

		<%
		TimerTask myTimerTask = new TimerTask() {
			public void run() {
		        	System.out.println("timer " + i);
				i++;
				if (i == 3) {
					System.out.println("OK");
					this.cancel(); 
					out.println("UPDATE UI!"); /* <-- error  */
				}
			}
		};

	Timer myTimer = new Timer();
	myTimer.schedule(myTimerTask, 0, 2000);
	%>
		</div>

How can I resolve this little problem?
Thanks a lot
Salvo

 
0
 

well if the first 2 System.out.println() dont launch errors than i would try being consistant and using "System." on the third also.

 
0
 

well if the first 2 System.out.println() dont launch errors than i would try being consistant and using "System." on the third also.

The problem is the "System.out" print the result on my eclipse console and NOT in the html page. I would update the html page content.

 
0
 

read this

<%= a-java-expression %>
<!--or-->
<jsp:expression> a-java-expression </jsp:expression>
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: