facebook

how to debug the inner class in jsp

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #230250 Reply

    data2000
    Member

    I have some problem to do the debug in jsp. I have inner class in my jsp, if i set breakpoint directly in it. it won’t stop at all. If i set breakpoint ourside it, when it call something in that class , i got source not found error. Any one know what’s wrong with it?

    #230275 Reply

    Riyad Kalla
    Member

    Can you please post all the information we request in the [URL=http://www.myeclipseide.com/PNphpBB2+file-viewtopic-t-393.html]Posting Guidelines[/URL] thread at the top of this forum? That will give us some context so that we can determine if this is an installation issue, a configuration problem, or a bug. Thanks.

    #241642 Reply

    Dexia
    Member

    Breakpoint works fine outside of the inner class (namely anywhere in the JSP) but not inside the Breakpoint.
    My configuration is :
    Eclipse Platform Version: 3.1.0 Build id: I20050401-1645
    No other plugin than MyEclipse.
    MyEclipse : 3.8.4 (+QF2-BetaFor3.1M6)
    JDK : 1.4.2_02 under Tomcat 5.0.28.

    I declared the inner class with <%! %> markup.. it is the only i believe.

    May be you can help me … Thank you.

    #241644 Reply

    Riyad Kalla
    Member

    Dexia,
    Can you posst a sample page for us to test with? I’ve personally never delt with inner classes in JSPs before, but I’m pretty sure it is considered a sin.

    #247514 Reply

    Dexia
    Member

    Sorry for the late answer …
    Here is the code with an inner private class in a Jsp (I also try as a public class).
    Although I agree on the point that it is a sin to have an inner class in Jsp, I confirm that the breakpoint is simply ignored ….
    Just put one breakpoint in the findRecursively(File baseDir) of the JarFinder inner class.
    Thank you…

    
    <!-- -->
    <!-- $Name:  $ $Revision: 1.3 $ ($Date: 2005/11/17 08:43:52 $) -->
    <!-- -->
    <%@ page language="java" import="java.util.*,java.io.*,java.util.jar.*" %>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    long pageDelay = System.currentTimeMillis();
    %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
        <head>
            <title>Ear Description</title>
            <meta http-equiv="pragma" content="no-cache">
            <meta http-equiv="cache-control" content="no-cache">    
        </head>
      
    <body bgcolor="#F0FAFA">
    
    <h1><font face="Verdana">EAR Description</font></h1>
    
    <%! 
    //    Inner classes then we use the %! mark up instead of %
    private class JarFinder
    {
        private FilenameFilter FILTER_ON_JAR = new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return name.endsWith("jar");
            }
        };
        
        private FileFilter FILTER_ON_DIRECTORY = new FileFilter() {
            public boolean accept(File pathname) {
                return pathname.isDirectory();
            }
        };
    
        /**
         * Inner class can't be static !
         * Returns a List of File denoting absolute path names.
         */
        public List findRecursively(File baseDir)
        {
            List result = new ArrayList();
            findRecursively(baseDir, result);
            return result;
        }
        
        /**
         *    Recursive method.
         */
        private void findRecursively(File currentDir, List result)
        {
            if (! currentDir.exists()) {
                throw new IllegalArgumentException(currentDir.getAbsolutePath() + " does not exist.");
            }
            if (! currentDir.isDirectory()) {
                throw new IllegalArgumentException(currentDir.getAbsolutePath() + " is not a directory.");
            }
        
            // Call the sub directories of the current directory
            File[] children = currentDir.listFiles(FILTER_ON_DIRECTORY);
            for (int i = 0; i < children.length; i++) {
                findRecursively(children[i], result);
            }
            
            // Get the JAR files
            File[] jarChildren = currentDir.listFiles(FILTER_ON_JAR);
            for (int i = 0; i < jarChildren.length; i++) {
                result.add(jarChildren[i]);
            }
        }
    }
    %>
    
    <table bgcolor="blue" width="100%" border="0" cellspacing="1" cellpadding="5">
    <tr>
    <td bgcolor="green"><font color="white"><b>Nom archive</b></font></td>
    <td bgcolor="green" title="<pre><u><b>Nom du Jar :</b></u><br>Contenu du fichier META-INF/MANIFEST.MF</pre>"><font color="white"><b>Version</b></font></td>
    <td bgcolor="green"><font color="white"><b>Path</b></font></td>
    <td bgcolor="green"><font color="white"><b>Taille (o.)</b></font></td>
    </tr>
    
    
    <%
        String earPhysicalRootPath = request.getRealPath("/") + "/.."; // If you use this JSP LOCALLY, remove the "/..". The / is required under Websphere
        File earRootDir = new File(earPhysicalRootPath);
        JarFinder jarFinder = new JarFinder();
        List jarFile = jarFinder.findRecursively(earRootDir);
        for (int i = 0; i < jarFile.size(); i++)
        {
            File file = (File) jarFile.get(i);
            String shortName = file.getName();
            long jarSize = file.length();
            long tag = file.lastModified();
            String manifestContent = "will be read from MANIFEST file";
            // Ugly way to transform Strings : "C:\LOCALAPP\Specific\Tomcat5\webapps\PrismWeb\..\PrismWeb\WEB-INF\lib\ant-commons-net.jar"
            //    into "/PrismWeb/WEB-INF/lib/ant-commons-net.jar".
            String relativeDirPath = file.getAbsolutePath().replace('\\', '/').replaceAll(earRootDir.getAbsolutePath().replace('\\', '/'), "");
    %>
    <tr bgcolor="#FFFFAA">
    <!-- RED color is <tr bgcolor="#ffa28b"> -->
    <td><b><%= shortName %></b></td>
    <td title="<pre><u><b><%= shortName %> :</b></u><br><%= manifestContent.replace('"', '\'') %></pre>"><%= tag %></td>
    <!-- <td></td> -->
    <td><%= relativeDirPath %></td>
    <td align="right"><%= jarSize %></td>
    </tr>
    <%
        }
    %>
    </table>
    <!-- for info : <%= earPhysicalRootPath %> -->
    
    <% pageDelay = System.currentTimeMillis() - pageDelay; %>
    <p align="right"><font size="-1"><i>Data retrieving in <%= pageDelay %> ms.</i></font></p>
      </body>
    </html>
    
    #247524 Reply

    Riyad Kalla
    Member

    Why don’t you just put this code into a Bean that the page uses? That would be about 10x easier to maintain and you wouldn’t be smoted by God then… two big pluses!

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: how to debug the inner class in jsp

You must be logged in to post in the forum log in