简体   繁体   中英

Is it better to ship WAR with class files of JSPs, instead of JSPs themselves?

If we can make Tomcat/Jasper compile JSPs using an ANT task, wouldn't it better to ship the WAR with pre-compiled JSPs as class files, rather than JSPs themselves?

That way, we are not tied down with Weblogic/Webshere JSP compilation issues. All that they would get are 'class' files.

I think this would need that the "jsp" servlet would have to be turned off somehow. And the Spring/Struts Servlet will have to enabled to handle 'jsp' extension.

What do you think? And what is the more commonly done thing in other production environments?

Compilation of JSPs has the following advantages.

  • You are sure it can be compiled, ie no surprises at runtime.
  • You save some time when user arrives to the JSP first time.

I think that the first advantage is important, the second one is not so important. I personally do not care if the first and only first user will wait additional second or two while the jsp is being compiled. But I care very much the now user will never get compilation error when he/she is using my application.

I think that it is enough compile JSPs during build just for validation and not pack produced .class files with your application. But distributing the .class files is fine too.

I would generally say no it's not better. I think it's too much trouble to go through, then just packaging the ear/war up and shipping.

If you're JSP's aren't compiling in production, and are compiling locally or in QA then you have other issues that need to be solved as well.

Compiled JSP are not portable across containers. They extend runtime specific classes. You can always try to embed your own JSP implementation, but that's a different problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM