JSP pre-compiled into a class file for JSP File Protection

Source: Internet
Author: User
Tags linux
Js| compiled in WebLogic Publishing Web Application project, in order to protect JSP files to avoid unauthorized access and peep, you can use WEBLOGIC.JSPC JSP file precompile into a servlet file, put to Web-inf The/classes directory. Based on the servlet declaration, Web-inf is not part of the common document tree for WEB applications. Therefore, the resources under the Web-inf directory is not directly service for customers, so that to some extent, to ensure the security of JSP.







The specific implementation steps are as follows (Weblogic for Linux):



1. Compile JSP file with WEBLOGIC.JSPC



(1) Under the Linux working directory, create the following shell file, file name is jspc.sh



#!/bin/sh



java_home=/opt/ibmjava2-131



Wbl_lib=/u11/bea/wlserver6.1/lib/weblogic.jar



Classpath=${java_home}/lib:.:${wbl_lib}



Target_dir=.. /mofa/web-inf/classes # This is the Repository directory for JSP compiled servlet files



Webapp_dir=.. /mofa # This is the directory of the Web application you want to publish



${java_home}/bin/java-classpath ${classpath} weblogic.jspc-k-g-compileall-d ${target_dir}-webapp ${WEBAPP_DIR}







The part of the blue font above is to be modified according to the user's own configuration.







(2) Set the executable property of the jspc.sh file



# chmod +x jspc.sh







(3) in the current directory, the implementation of jspc.sh files, JSP files compiled, compiled class files, should be in the Web-inf/classes/jsp_servlet directory.







2, then has been successful, from the Web application in the directory of all the JSP removed or deleted.







3, edit Weblogic.xml file, the contents of the Jsp-descriptor label empty, add the following content:



<jsp-descriptor>



<jsp-param>



<param-name>precompile</param-name>



<param-value>false</param-value>



</jsp-param>



<jsp-param>



<param-name>pageCheckSeconds</param-name>



<param-value>-1</param-value>



</jsp-param>



</jsp-descriptor>







4, edit the Web.xml file, add the following content:



<servlet>



<servlet-name>JSPClassServlet</servlet-name>



<servlet-class>weblogic.servlet.JSPClassServlet</servlet-class>



</servlet>



<servlet-mapping>



<servlet-name>JSPClassServlet</servlet-name>



<url-pattern>*.jsp</url-pattern>



</servlet-mapping>







5, publish this Web application on the WebLogic.







6, access to the corresponding JSP files, if the access to success, indicating the whole process is no problem








Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.