Hiding JSP code during deploynment in tomcat5

I have developed a JSP application using JSP pages,Servlets and JavaBeans and i would reaaly like to hide my JSP code.
Since JSP pages have to be converted to Java Sources and then to classes, is there a way i can deploy only the class files sumped by my tomcat? Please assist because i am desperate with this solution

Hi
This thing can be done. Let me give u an example
suppost i have a context named Test in webapps directory. it contains
a jsp named hello.jsp.Now start Tomcat, access the hello.jsp file
eg:
http://localhost:8080/Test/hello.jsp
Now it will compile the jsp and the servlet version of the jsp will be created in work\Catalina\localhost\Test\ . inside this directory the servlet of the corresponding JSP gets created with following package
org.apache.jsp.hello_jsp.java
inside org/apache/jsp directory u will find the hello_jsp.java and hello_jsp.class File.We will require only class file.Delete the .java file
make a jar of org.apache.jsp.hello_jsp say test.jar
Now copy test.jar to webapps/Test/web-inf/lib
edit the web.xml like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
<servlet>
     <servlet-name>HelloServlet</servlet-name>
     <servlet-class>org.apache.jsp.hello_jsp</servlet-class>     
</servlet>
<servlet-mapping>
     <servlet-name>HelloServlet</servlet-name>
     <url-pattern>/hello.jsp</url-pattern>
</servlet-mapping>
</web-app>now delete the hello.jsp start Tomcat and try acess the jsp
Hope everything will work fine...
regards
Suvendu

Similar Messages

  • Hiding JSP codes. Pls help.

    Dear experts,
    After completion of web development, I have to upload my file to the hosting site.
    Is there any way to hide the JSP code so that the System Administrator of the hosting site also cannot
    view the code.
    From
    jeff

    Hi iragavar,
    HOW TO OBFUSCATE THE CLASS FILES
    To Obfuscate class files you can use Obfuscators
    Java compilers place uncessary symbolic information in your .class files that makes them extremely vulnerable to reverse engineering by leaving method and field names unaltered from the original source. Obfuscator removes this information.
    There are number of obfuscators available in market, you can use any. You can have a look at few at the following URLs.
    http://2lkit.com/products/2LKitObf/
    http://www.e-t.com/jshrinkdoc.html
    http://www.duckware.com/jobfuscate.html
    Hope this helps

  • Error While running the JSP Code

    This is the error message:
    A java exception has occurred during the processing of this request.
    Error occurred in JSP element starting at line number 20
    javax.servlet.jsp.JspTagException: I/O Error: java.net.SocketException: Connection reset
         at desisoft.jsp.tagext.SendMail.doAfterBody(SendMail.java:213)
         at desisoft_jsp_SendMail_jsp1139292195218._jspService(desisoft_jsp_SendMail_jsp1139292195218.java:111)
         at desisoft.server.JspBaseClass.service(JspBaseClass.java:48)
    The JSP code:
    <%@ taglib prefix="blx" uri="/blx.tld" %>
    <HTML>
    <BODY>
    <%
    // Get username.
    String email = request.getParameter( "email" );
    %>
    <% if ( email == null || email.equals( "" )) { %>
    Please enter an email address.
    <% } else { %>
    <blx:email host="mail.xxx.com" from="[email protected]">
    <blx:emailTo><%= email %></blx:emailTo>
    Thank you for registering with us. You registered the
    following name: <%= request.getParameter( "username" ) %>
    Your registration was received at <%= new java.util.Date() %>
    Attached, please find a contents file.
    </blx:email>
    <!-- Also write out some HTML -->
    Thank you. A confirmation email has been sent to <%= email %>
    <% } %>
    </BODY>
    </HTML>

    This is the error message:
    A java exception has occurred during the processing of this request.
    Error occurred in JSP element starting at line number 20
    javax.servlet.jsp.JspTagException: I/O Error: java.net.SocketException: Connection reset
         at desisoft.jsp.tagext.SendMail.doAfterBody(SendMail.java:213)
         at desisoft_jsp_SendMail_jsp1139292195218._jspService(desisoft_jsp_SendMail_jsp1139292195218.java:111)
         at desisoft.server.JspBaseClass.service(JspBaseClass.java:48)
    The JSP code:
    <%@ taglib prefix="blx" uri="/blx.tld" %>
    <HTML>
    <BODY>
    <%
    // Get username.
    String email = request.getParameter( "email" );
    %>
    <% if ( email == null || email.equals( "" )) { %>
    Please enter an email address.
    <% } else { %>
    <blx:email host="mail.xxx.com" from="[email protected]">
    <blx:emailTo><%= email %></blx:emailTo>
    Thank you for registering with us. You registered the
    following name: <%= request.getParameter( "username" ) %>
    Your registration was received at <%= new java.util.Date() %>
    Attached, please find a contents file.
    </blx:email>
    <!-- Also write out some HTML -->
    Thank you. A confirmation email has been sent to <%= email %>
    <% } %>
    </BODY>
    </HTML>

  • Help on jsp code to display data in same page using using ajax ?

    Is there any jsp code to display in same page using using ajax ?

    Re: need help on how to display data in same jsp page. Locking.

  • Is there a way of embedding JSP code in VBScript?

    I am launching MS Excel using VBScript in the JSP Page. I want to populate the spread sheet with the values coming from a Java Bean. I am not sure how I can embed JSP code in VBScript.
    Thanks

    I tried doing that with Javascript but it gives me error..
    here is the code I was testing..
    <script language="JavaScript">
    function test(){
    var name = <%=(bean.getName())%>;
    alert(name);
    </script>
    <input type="button" name="Button" value="test" onClick=javascript:test()>
    Error : Object Expected
    If I do a similar thing with VBScript, it doesnt work either.
    here is the test code for VBScript
    <SCRIPT LANGUAGE="VBScript">
    sub button1_onclick()
         dim name = <%=(bean.getName())%>
    ' Launch Excel
    dim app
    set app = createobject("Excel.Application")
    ' Make it visible
    app.Visible = true
    set rng2 = wb.Activesheet.Range("A1").Resize(2,2)
    rng2.value = name
    ' Give the user control of Excel
    app.UserControl = true
    end sub
    </SCRIPT>

  • How to access a JAVA Script variable in JSP Code

    How to access a JAVA Script variable in JSP Code. I have been unable todo this.
    Plz Suggest a way.
    Thanks
    Soumya

    try to do this code
    String s=request.getParameter("javascriptvariablename");

  • How to get OutputStream/Writer for a file in a JSP code?

    In a JSP code as shown below, how could we get an OutputStream to write a file that resides on the server file system?
    I'm stuck after five hours struggle!
    <%
    /* simple experimental JSP program */
    ...  // get request data
    Properties pt = new Properties();
    Class clas = getClass();
    InputStream is = clas.getResourceAsStream("/users.properties");
    pt.load(is);
    String userNameDB = pt.getProperty("user");
    String passwordDB = pt.getProperty("password");
    long lastLogonDB = Long.parseLong(pt.getProperty("lastLogon"));
        // so far so good ...
    if (userName.equals(userNameDB) && password.equals(passwordDB)){
      if (lastLogonForm > lastLogonDB) {
        session.setAttribute("User", userName); //Saves user name string in the session object
        pt.setProperty("lastLogon", lastLogon);
        pt.setProperty("user", userNameDB);
        pt.setProperty("password", passwordDB);
        ...  // how to write back the new data to the users.properties file?
    %>

    I have found a solution:
    String path = application.getRealPath("/users.properties");
    InputStream is = new FileInputStream(path);
    is.close();
    OutputStream os = new FileOutputStream(path);
    os.close();getResourceAsStream() is oddly incompatible with the code using the getRealPath(). So don't use it.

  • JSP codes for running a JAVA program

    hello...
    does anyone know the JSP codes for running a Java program from my web page?? i mean i already have my java program compiled... and i just want this java program to run in the background when I click on a button or a link...
    Any idea about this?
    plz advice..
    avi

    yes... u r somewhat right... but this runs on Jakarta Tomcat...
    i'm using the Apache Http Server together with the ServletExec AS which enable the Apache server to run JSP..
    I've created a package where i've put my classes...
    WEB-INF/classes/tbd(package name)/my classes
    and i've added.. package name.. in my java program..
    and then in jsp... i've written..
    <%@ page import="tdb.*"%>
    <jsp:useBean id="exec" class="tdb.textdb" />
    <%exec.convert_data();%>
    but when i run the page it says the package does not exist...
    can anyone tell where to place the folder WEB-INF so that it can run fine?
    thx
    avi

  • The content code I got was said as not reconised valid code during redemption of Up-to-date Program?

    I have registered for up-to-date program. However the content code I received was said as not recognised valid code during redemption. What can I do?

    The Apple Support Communities are an international user to user technical support forum. As a man from Mexico, Spanish is my native tongue. I do not speak English very well, however, I do write in English with the aid of the Mac OS X spelling and grammar checks. I also live in a culture perhaps very very different from your own. When offering advice in the ASC, my comments are not meant to be anything more than helpful and certainly not to be taken as insults.
    Folks report a two email process; one with a secure pdf that has the redemption code and another with the password to open the secure pdf.

  • How to download files in jsp code {through save dialog}

    can you help me to download files in jsp code {through save dialog}
    i use the following code but it saves the jsp page instead of the downloaded file but with the name of the wanted file to be downloaded
    response.setHeader("Pragma", "public");
    response.setHeader("Cache-Control", "no-cache");
    *** download file
    if((trans !=null)&&(trans.equals("download")) )
    response.setContentType ("application/x-download");
    response.setHeader ("Content-Disposition","attachment;filename=\""+fileName+"\"");
    %>
    <script>
    window.location.href=<%=gallerypath+fileName%>';
    </script>
    <%
    trans="";
    //System.out.print("download : "+fileName );
    //***************************************

    Can you try below code, It should work...
    <%
    String myFileName = request.getParameter("fileName");
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition", "attachment; filename=\"" + myFileName + "\"");
    String root = "D:/";
    InputStream in = null;
    ServletOutputStream outs = response.getOutputStream();
    try {
    in = new BufferedInputStream
    (new FileInputStream(root + myFileName));
    int ch;
    while ((ch = in.read()) != -1) {
    outs.print((char) ch);
    finally {
    if (in != null) in.close(); // very important
    outs.flush();
    outs.close();
    in.close();
    %>

  • How to use enviroment variables in JSP code?

    I�m developing a web server with JSP�s, and I need to move the application to others computers. I need to access to a directory, but I don�t know it because the user can install the Application in the directory he wants. So I need to access to that directory in the JSP code.
    The directory is "C:\Program Files\....\tomcat\webapps\ROOT\upload". I have the CATALINA_HOME enviroment variable defiened as "C:\Program Files\....\tomcat\", so I need to use something like "CATALINAHOME\\webapps\upload\", but I don�t know how to mekr the JSP code to understand the enviroment variable CATALINA_HOME.
    I�ve tried with %CATALINA_HOME%, but the Tomcat server doesn�t recognize it. How can I access to that directory?
    Thanks (Sorry about my english)

    My JSP�s are in: %CATALINA_HOME%\webapps\ROOT\
    I wan�t to access to %CATALINA_HOME%\webapps\ROOT\upload\
    My JSP code:
    <% ...
    String DPATH = "C:\\Program Files\\JBuilder7\\jakarta-tomcat-4.0.3\\webapps\\ROOT\\upload\\";
    File newfile = null;
    newfile = new File(DPATH+filename);
    %>
    I want the JSP to locate the directory \webapps\ROOT\upload\ without knowing the complete route "c:\Program Files\...", because I have the enviroment variable CATALINA_HOME with the value "C:\Program Files\JBuilder7\jakarta-tomcat-4.0.3\". SO the user of the aplication only has to set the CATALINA_HOME variable and the aplication should access the upload directory throught the CATALINA_HOME variable.
    I can�t explain it better. Sorry.

  • How to use protected method in jsp code

    Could anyone tell me how to use protected method in jsp code ...
    I declare a Calendar class , and I want to use the isTimeSet method ,
    But if I write the code as follows ..
    ========================================================
    <%
    Calendar create_date = Calendar.getInstance();
    if (create_date.isTimeSet) System.out.println("true");
    %>
    ============================================================
    when I run this jsp , it appears the error wirtten "isTimeSet has protected access in java.util.Calendar"

    The only way to access a protected variable is to subclass.
    MyCalendar extends Calendar
    but I doubt you need to do this. If you only want to tell if a Calendar object has a time associated with it, try using
    cal.isSet( Calendar.HOUR );

  • Jsp code doesnt run if redirected to the page

    When I see page.jsp for the first time, the jsp code in it executes, but when I revisit thet page, the jsp code doesn?t.
    The jsp code writes a number, and that number is shown. the first time I get a number 1, and the second I should get a number 2. but I?m getting a number 1 all the time. If I reload the page, then I get a number 2.
    Is like I?m getting the local cache html version of the page.
    I think it has to do with the way I get to the page. I get to the page using:
      response.sendRedirect("page.jsp");from another jsp page, or
      getAppletContext().showDocument("blablabla/page.jsp");from an applet.

    The browser is probably cahcing the page and not sending the request to get an updated page.
    Either set you browser settings or add this to the top of the jsp:
    <% response.setHeader("Pragma", "no-cache");
       response.setHeader("Cache-Control", "no-cache");
       response.setDateHeader("Expires", 0); %>

  • ERROR!!! ~JSP CODES~

    Any problem with the following jsp code?
    <%@ page import="
    java.io.*,
    java.util.*"
    %>
    <%
    boolean login_ok = false;
    Boolean result_obj = new Boolean(login_ok);
    result_obj = (Boolean)request.getAttribute("result");
    login_ok = result_obj.booleanValue();
    %>
    <html>
    <head>
    <title>Login results page</title>
    </head>
    <body>
    <%
    if (login_ok){
    %>
    <p>Login Successful!</p>
    <%
    else{
    %>
    <p>Login Failure!</p>
    <%
    %>
    </body>
    </html>
    It returns the following error:
    Exception in jsp: null
    java.lang.NullPointerException
         at _0005ctest_0002ejsptest_jsp_3._jspService(_0005ctest_0002ejsptest_jsp_3.java:71)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:868)
         at org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.java:161)
         at org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:255)
         at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:360)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:868)
         at com.gefionsoftware.server.ServletContextImpl$ServletHandler.call(ServletContextImpl.java)
         at com.gefionsoftware.server.ServletContextImpl.executeServlet(ServletContextImpl.java)
         at com.gefionsoftware.server.ServletContextImpl.execute(ServletContextImpl.java)
         at com.gefionsoftware.server.GenericServer.execute(GenericServer.java)
         at com.gefionsoftware.server.lws.LiteWebServer$RequestHandler.run(LiteWebServer.java)
         at se.pureit.util.ThreadPool$WorkThread.startRunnable(ThreadPool.java)
         at se.pureit.util.ThreadPool$WorkThread.run(ThreadPool.java)

    Hope you are getting a null-pointer exception here :
    result_obj = (Boolean)request.getAttribute("result");
    login_ok = result_obj.booleanValue();
    Make sure that the request attribute value is not null.
    Hope this helps
    Santhosh

  • Jsp code for image compression

    Hai,sir this is surendra i am doing a project using jsp and mysql.
    In that each user can put his image and i am storing that image in mysql blob but that results to that database size.
    So i need jsp code for image compression or another way for storing images.

    There's no need to store images in db. You may store them in a dedicated folder.

Maybe you are looking for