• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP compilation

 
rushikesh kalikar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Below code works fine on first time but second time it will not work .

BasicCounter.jsp

<html>
<body>
The page count is :
<%out.println(Counter.getCount())%>;
</body>
</html>

------------------------------------------------------

package foo;

public class Counter{
private static int count ;
public static synchronized int getCount(){
count++;
return count;
}
}
----------------------------------------------------
I am not able to understand why it is working for first time ?
Please reply .

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before I tried the code, what is the output for the second time? Did you get any exception?
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess Rushikesh you always get the same output instead of increasing count. It might be due to browser caching, but I'm just guessing...
 
rushikesh kalikar
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Second time I am getting exception " Unable to compile jsp" but first time it deploys successfully.
 
Tapas Chand
Ranch Hand
Posts: 583
8
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP compilation is one-time activity. It is compiled when first time it is accessed and is loaded into memory.
On further access, it is accessed from memory.
Can you post the exact error and can you explain what exactly are doing? This will be helpful in identifying the root cause.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic