This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

modifying generated servlet code

 
John David
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
respected folks!
what will happen if we modify the generated servlet code in the jsp file ?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably nothing. What happened when you tried it?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you've configured your container to do otherwise, it will do nothing (as Ulf said) until you touch the JSP file; at which time, your modified Java file will be overwritten with a new version of the generated servlet code and that will be compiled into a servlet class.
 
chinna reddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If you modify only servlet code(.java) without compiling manually,nothing will happend. Because based on the jsp timestamp and .class timestamp the latest will get executted. But if you compile the code then your modified class will execute irrespective of jsp(If you dont touch jsp).If you modify the jsp then your class file will overite by jspcompiler.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by chinna reddy:
But if you compile the code then your modified class will execute irrespective of jsp(If you dont touch jsp).


Are you sure about that? I would have assumed that the container reloads the class if the JSP has changed. Since nobody but the container should mess with the .java and .class files, there's little point in checking modification times on those.
 
paritosh ranjan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does the container checks?
Change in .jsp file or change in .java file.
 
subodh gupta
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lets see what happens...

1) You started the server the jsp got translated and then compiled to class file let say Test_jsp.class with output result of "Hello World".
2) Now you taken the Test_jsp.java file and changed the message to "Hello Wrold! I have done it." and compiled and and replace the .class file.
3) Try to run the file.
4) Is jsp changed? no.
5) Class rebuild required? No.
6) Output "Hello Wrold! I have done it."
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic