File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A very simple question: not able to understant: Pl help!!

 
Sudeepa Basu
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
According to JSP specs, variables are declared with the following syntax:
<%! name=value %>
How come the code below which i by chance modified from wrox book works perfectly on java web server. It should give compilation erorr:
<html>
<body>
<% int i = 1; %>
<% for (int x=0; x<5; x++) { out.println("value of i is: is :"+ i); } %>
</body>
</html>
Please tell me the reason. It would be a great help.
thanks a lot in advance
sudeepa
 
Vijay Kashyap
Ranch Hand
Posts: 74
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sudeepa Basu,
Initially you have declared it as a global(instance) variable <%! int i = 0;%>, hence they are shared between different invokation of same jsp.
You have changed it to local variable <% int i = 0;%>, hence its still working. Now the variable i is local variable for method _jspService ( ...), which you would get when jspengine converts your jsp to java file.
Hope this helps,
Vijay
[This message has been edited by vijay kashyap (edited August 29, 2001).]
 
Sudeepa Basu
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot vijay.
I got it!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic