⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 servlet.html

📁 jdbc书
💻 HTML
📖 第 1 页 / 共 2 页
字号:
49      out.println("<head>
                     <title>Snoop Servlet
                     </title></head>");
Thread-105[1] 
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">
The servlet can continue using the <CODE>cont</CODE> command.
</FONT>

<PRE>
Thread-105[1] cont
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<A NAME="web"></A>
<H3>Running Java Web Server in Debug Mode</H3>

The JSDK release does not contain classes available in the Java
Web server and it also has its own special servlet configuration.
If you cannot run your servlet from <CODE>servletrunner</CODE>,
then the other option is to run the Java Web server in debug mode. 

<P>
To do this add the <CODE>-debug</CODE> flag for the first parameter after the 
<CODE>java</CODE> program. For example in the script <CODE>bin/js</CODE>
change the JAVA line to look like the following. In releases prior to 
the Java 2 platform release, you will also need to change the program pointed 
to by the variable $JAVA to <CODE>java_g</CODE> instead of <CODE>java</CODE>.

</FONT>

<PRE>
Before:

exec $JAVA $THREADS $JITCOMPILER $COMPILER $MS $MX \

After:

exec $JAVA -debug $THREADS $JITCOMPILER 
                                  $COMPILER $MS $MX \

</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">
<P>
Here is how to remotely connect to the Java Web Server.
The agent password is generated on the standard output from the Java
Web Server so it can be redirected into a file somewhere.
You can find out where by checking the Java Web Server startup scripts.

</FONT>

<PRE>
jdb -host localhost -password &lt;the agent password&gt;
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

The servlets are loaded by a separate classloader if they are contained 
in the <CODE>servlets</CODE> directory, which is not on the <CODE>CLASSPATH</CODE>
used when starting the Java Web server. Unfortunately,
when debugging remotely with <CODE>jdb</CODE>, you cannot control the custom 
classloader and request it to load the servlet, so you have to either include
the <CODE>servlets</CODE> directory on the <CODE>CLASSPATH</CODE> for debugging 
or load the servlet by requesting it through a web browser and then placing
a breakpoint once the servlet has run.

<P>
In this next example, the <CODE>jdc.WebServer.PasswordServlet</CODE> is included
on the <CODE>CLASSPATH</CODE> when Java Web server starts. The example
sets a breakpoint to stop in the <CODE>service</CODE> method of this servlet,
which is the main processing
method of this servlet.

<P>
The Java Web Server standard output produces this message, which 
lets you proceed with the remote <CODE>jdb</CODE> session:

</FONT>

<PRE>
Agent password=3yg23k
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

</FONT>

<PRE>
$ jdb -host localhost -password 3yg23k
Initializing jdb...
&gt; stop in jdc.WebServer.PasswordServlet:service
Breakpoint set in jdc.WebServer.PasswordServlet.service
&gt; stop
Current breakpoints set:
        jdc.WebServer.PasswordServlet:111
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

<P>
The second <CODE>stop</CODE> lists the current breakpoints in this session
and shows the line number where the breakpoint is set. You can now call
the servlet through your HTML page. In this example, the servlet is run as
a POST operation

</FONT>

<PRE>
&lt;FORM METHOD="post" action="/servlet/PasswordServlet"&gt;
&lt;INPUT TYPE=TEXT SIZE=15 Name="user" Value=""&gt;
&lt;INPUT TYPE=SUBMIT Name="Submit" Value="Submit"&gt;
&lt;/FORM&gt;
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">

<P>
You get control of the Java Web Server thread when the breakpoint
is reached, and you can continue debugging using the same techniques
as used in the <A HREF="running.html#remote">Remote Debugging</A> section.

</FONT>

<PRE>
<FONT SIZE="-1">
Breakpoint hit: jdc.WebServer.PasswordServlet.service 
(PasswordServlet:111) webpageservice Handler[1] where
[1] jdc.WebServer.PasswordServlet.service 
                               (PasswordServlet:111)
[2] javax.servlet.http.HttpServlet.service 
                               (HttpServlet:588)
[3] com.sun.server.ServletState.callService 
                               (ServletState:204)
[4] com.sun.server.ServletManager.callServletService 
                               (ServletManager:940)
[5] com.sun.server.http.InvokerServlet.service 
                               (InvokerServlet:101)
</FONT>
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">
A common problem when using the Java WebServer and other servlet environments
is that Exceptions are thrown but are caught and handled outside the
scope of your servlet. The <CODE>catch</CODE> command allows you to trap 
all these exceptions.
</FONT>

<PRE>
<FONT SIZE="-1">
webpageservice Handler[1] catch java.io.IOException
webpageservice Handler[1] 
Exception: java.io.FileNotFoundException        
 at com.sun.server.http.FileServlet.sendResponse(
                                FileServlet.java:153)
 at com.sun.server.http.FileServlet.service(
                                FileServlet.java:114)
 at com.sun.server.webserver.FileServlet.service(
                                FileServlet.java:202)
 at javax.servlet.http.HttpServlet.service(
                                HttpServlet.java:588)
 at com.sun.server.ServletManager.callServletService(
			        ServletManager.java:936)
 at com.sun.server.webserver.HttpServiceHandler
           .handleRequest(HttpServiceHandler.java:416)
 at com.sun.server.webserver.HttpServiceHandler
           .handleRequest(HttpServiceHandler.java:246)
 at com.sun.server.HandlerThread.run(
                                HandlerThread.java:154)
</FONT>
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">
This simple example was generated when the file was not found, but this
technique can be used for problems with posted data. Remember to use
<CODE>cont</CODE> to allow the web server to proceed. To clear this
trap use the <CODE>ignore</CODE> command.
</FONT>

<PRE>
<FONT SIZE="-1">
webpageservice Handler[1] ignore java.io.IOException
webpageservice Handler[1] catch
webpageservice Handler[1] 
</FONT>
</PRE>

<FONT FACE="Verdana, Arial, Helvetica, sans-serif">


<P ALIGN="RIGHT">
<FONT SIZE="-1">[<A HREF="#top">TOP</A>]</FONT>

</FONT>
</TD>
</TR>
</TABLE>




<!-- ================ -->
<!-- End Main Content -->
<!-- ================ -->

</TD>
</TR>
</TABLE>

<!-- Copyright Insert -->

<BR CLEAR="ALL">

<FORM ACTION="/cgi-bin/search.cgi" METHOD="POST">
<TABLE WIDTH="100%" CELLPADDING="0" BORDER="0" CELLSPACING="5">   
  <TR>
    <TD VALIGN="TOP">
	
    <P ALIGN=CENTER>
    <FONT SIZE="-1" COLOR="#999999" FACE="Verdana, Arial, Helvetica, sans-serif">
    [ This page was updated: <!-- new date --> 13-Oct-99 ]</font></P>
    </TD>
  </TR>
  
  <TR>
    <TD BGCOLOR="#CCCCCC">
    <IMG SRC="/images/pixel.gif" HEIGHT="1" WIDTH="1" ALT=""></TD>
  </TR>
  
  <TR>
    <TD>
    <CENTER>
    <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
    <A HREF="http://java.sun.com/products/">Products &amp; APIs</A> | 
    <A HREF="/developer/index.html">Developer Connection</A> | 
    <A HREF="/developer/infodocs/index.shtml">Docs &amp; Training</A> | 
    <A HREF="/developer/support/index.html">Online Support</A><BR>
    <A HREF="/developer/community/index.html">Community Discussion</A> |
    <A HREF="http://java.sun.com/industry/">Industry News</A> | 
    <A HREF="http://java.sun.com/solutions">Solutions Marketplace</A> | 
    <A HREF="http://java.sun.com/casestudies">Case Studies</A>
    </FONT>
    </CENTER>
    </TD>
  </TR>
  
  <TR>
    <TD BGCOLOR="#CCCCCC">
    <IMG SRC="/images/pixel.gif" HEIGHT="1" WIDTH="1" ALT=""></TD>
  </TR>

  <TR>
    <TD ALIGN="CENTER">
    <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
    <A HREF="http://java.sun.com/docs/glossary.html">Glossary</A> - 
    <A HREF="http://java.sun.com/applets/">Applets</A> - 
    <A HREF="http://java.sun.com/docs/books/tutorial/">Tutorial</A> - 
    <A HREF="http://java.sun.com/jobs/">Employment</A> - 
    <A HREF="http://java.sun.com/nav/business/">Business &amp; Licensing</A> - 
    <A HREF="http://java.sun.com/javastore/">Java Store</A> -
    <A HREF="http://java.sun.com/casestudies/">Java in the Real World</A>
    </FONT>
    </TD>
  </TR>

  <TR>
    <TD>
    <CENTER>
    <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
    <a href="/siteinfo/faq.html">FAQ</a> |
    <a href="/feedback/index.html">Feedback</a> | 
    <a href="http://www.dynamicdiagrams.net/mapa/cgi-bin/help.tcl?db=javasoft&dest=http://java.sun.com/">Map</a> | 
    <A HREF="http://java.sun.com/a-z/index.html">A-Z Index</A>
    </FONT>
    </CENTER>

    </TD>
  </TR>
  
  <TR>
    <TD>

    <TABLE WIDTH="100%" CELLPADDING="0" BORDER="0" CELLSPACING="0">
      <TR>
        <TD WIDTH="50%">
        <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
        For more information on Java technology<BR>
        and other software from Sun Microsystems, call:<BR>
        </FONT>
        <FONT SIZE="-1" FACE="Verdana, Arial, Helvetica, sans-serif">
        (800) 786-7638<BR></FONT>
        <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
        Outside the U.S. and Canada, dial your country's 
        <A HREF="http://www.att.com/business_traveler/attdirecttollfree/">AT&amp;T&nbsp;Direct&nbsp;Access&nbsp;Number</A> first.<BR>
        </FONT>
        </TD>

        <TD ALIGN="RIGHT" WIDTH="50%">
        <A HREF="http://www.sun.com"><IMG SRC="/images/lgsun.gif" width="64" height="30" border="0" ALT="Sun Microsystems, Inc."></A><BR>
        <FONT SIZE="-2" FACE="Verdana, Arial, Helvetica, sans-serif">
        Copyright &copy; 1995-99
        <A HREF="http://www.sun.com">Sun Microsystems, Inc.</A><BR>
        All Rights Reserved. 
        <a href="http://www.sun.com/share/text/SMICopyright.html">Legal Terms</a>. 
        <A HREF="http://www.sun.com/privacy/">Privacy&nbsp;Policy</A>.
        </FONT>
        </TD>
      </TR>
    </TABLE>
	
    </TD>
  </TR> 
</TABLE>
</FORM>

<!-- End Copyright Insert -->


</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -