aspose file tools*
The moose likes Servlets and the fly likes modifying generated servlet code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "modifying generated servlet code " Watch "modifying generated servlet code " New topic
Author

modifying generated servlet code

John David
Greenhorn

Joined: Aug 17, 2006
Posts: 29
respected folks!
what will happen if we modify the generated servlet code in the jsp file ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41838
    
  63
Probably nothing. What happened when you tried it?


Ping & DNS - my free Android networking tools app
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
chinna reddy
Greenhorn

Joined: Jul 17, 2007
Posts: 3
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
Marshal

Joined: Mar 22, 2005
Posts: 41838
    
  63
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

Joined: Aug 24, 2007
Posts: 62
What does the container checks?
Change in .jsp file or change in .java file.
subodh gupta
Ranch Hand

Joined: Jul 23, 2007
Posts: 203
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."


http://subodh-gupta.blogspot.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: modifying generated servlet code