0

where are the .class files reside that are converted from .jsp files ?

I have .war file that contains .jsp files but I dont want those to give to my client yet.

I do not want to give .jsp files (as it has the source) but just the .class files so that the website is run-able, but not amendable.

What options do I have?

Popeye
  • 11,839
  • 9
  • 58
  • 91
kevin
  • 328
  • 4
  • 15
  • 33
  • 1
    Keep in mind that it's still possible to decompile the generated servlets. IMHO, it does not make sense to deliver just the compiled JSPs (servlets), instead it just makes build and deployment more complex... – home Feb 18 '13 at 17:30
  • what if I delete the .war file once it has been extracted by tomcat? (to make it simple) – kevin Feb 18 '13 at 18:09
  • As long as the .class files are on disk it's possible to decompile them - this is how Java works... – home Feb 18 '13 at 18:29
  • it would be difficult and will not give the exact results and a coded .java / .jsp is. thats all i need – kevin Feb 18 '13 at 19:07

2 Answers2

1

You need JSP precompilation. During build-time some tool (jspc) does what typically Tomcat is doing on demand when JSP is first loaded - compiles them into servlets and generates appropriate web.xml snippet.

When you generate servlets for all JSP files, it's safe to delete them. It's a good idea to avoid checking in generated servlets to VCS.

See JSP Compilation Support for Maven 2 and How can I make Tomcat pre-compile JSPs on startup?.

Community
  • 1
  • 1
Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
1

Your question has been answered here: "Where are compiled JSP Java (*_jsp.java) files?".

The compiled JSP files are by default available in the /work folder of the Tomcat environment.

Or, if you're using Eclipse IDE and publish the application within the workspace, which is the default behaviour, you may find the work directory in some path like:

workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\HelloWorld\org\apache\jsp\test_jsp.class

However, if you want all the compiled JSP (*_jsp.class) files, you have these options: Use Tomcat jspc tool with ant as instructed on the documentation; use wget to recursively request all the *.jsp pages from the tomcat server by issuing a command like below, or use your IDE's precompile JSP pages option to let the IDE do the job for you.

wget -r --no-parent -A.jsp http://domain/your-project/

so that it should all be cached by tomcat now.

Community
  • 1
  • 1
neuro_sys
  • 805
  • 7
  • 13
  • what if I delete the .war file once it has been extracted by tomcat? (to make it simple) – kevin Feb 18 '13 at 18:08