开发者

convert java server pages to servlets

is it 开发者_如何学Cpossible to convert java server pages to servlets ?


JSPs are compiled to a Servlet on the server the first time you access them. This is one of the reasons why you need a JDK instead of a JRE when running a Servlet container or Java EE stack... unless the server itself comes with a Java compiler, like Tomcat does.

Depending on the server, there may be methods to precompile JSPs when you initially deploy the application, or if you deploy using Maven, by configuring Maven to use the jspc plugin.


jsp files are compiled to servlets automaticly, so you needn't compile by yourself. If you are using Tomcat you can look at this servlets - java classes. It's in:

Tomcat/work/Catalina/localhost/[my-web-app]/org/apache/jsp

Work directory is created when you start your Tomcat server, so before you check, start Tomcat :)

If you are using different container check documentation.


jsp are compiled to servlets. In fact you might have a jsp which does not render anything and which is going to be your servlet. BTW, why do you want to do something like this?


If you want to do the translation on the command line, you could use https://github.com/bnoqlr/jsppreproc which is just a wrapper for jspc. After compiling the wrapper by running mvn package, you can simply run java -jar target/jsppreproc-1.0-SNAPSHOT.jar -d /tmp some.jsp. You will find the servlet (.java file) with inside the /tmp directory.


Tomcat/work/Catalina/localhost/[my-web-app]/org/apache/jsp

lukastymo he say right but you just rename the class name and file name to JSP convert to Servlets But it is not necessory

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜