Servlets design - use singletons??

I am building a servlet to handle incoming POST connections. The user can send information to be added to the database. I have a servlet to handle the HTTP connection and a seperate class to handle the database interaction.
Currently the database class is a normal class and a new one is created in the init() method of the servlet. What is the best way to do this? Should the db class be a singleton or what should happen?
Also I have a seperate servlet to handle a different type of request, this one is required to handle a request to send an automatic text message. It needs to access the database as well but it will have to create a new db object to do so...
What are the advantages/disadvantages of using singletons in a servlet context? I understand that garbage collection is quite a serious overhead in a server environment so its best to reduce it.
thanks for your time.

Thanks for the reply. What are the performance considerations with using just one instance of a class? Lets say 10 requests come in at the same time that need to use the same methods in the singleton. Will they just sit and wait for it to become free?
just be careful when using multithreadingCan this problem not be avoided my adding the synchronised keyword to the methods in the singleton class?

Similar Messages

  • Can I Use Singletone  Pattren for DAO in Stateless EJB?

    Hi friends,
    I have a design in which i am creating an Business Layer using EJB (Stateless). In my case i have only read only to DataBase and at one case where i will be updating the database. But my application will be accessed by many concurrent users.
    My problem is if i create a DAO with singleton pattren then it will be returning the same instance to all the person who access the DB. So if one person is reading the database and at the same moment one more person request for update since the DAO is singleton object will there be any conflict?
    Reply soon

    Hi Martin.S
    Thanks for your suggestion.
    U Asked
    You need to think about why have you have made your DAO a Singleton. You need to ask yourself, SHOULD it be a Singleton? It may be valid decision but I find that doubtful. Singleton DAO's suit only limited set of circumstances. Why i decided to use singleton pattren was :
    Since i am using session bean and if i won't use Singleton pattren and
    If my app was used by say 1000 users
    Then 1000 Dao instaces whould be created!
    The App Server will have 1000 refrences which may be a performance issue and may slow down the server due to more usage of server resource. So i need to know weather is it a good idea to use the Singleton pattren for DAO when using SessionBeans?
    And one more doubt I have Martin
    If i use One Dao Class Per One Table Then How about the factories if i use singleton? Need to create so many factories as DAO's? *reply
    Also i think if i use Single DAO per Table and if i have say 1 user accessing the DAO and he is in the Middle of his execution and user 2 requests for the same DAO once again the situation is worse! Am i right?
    So I think Singleton pattren comes into handy only when one person is accessing the DAO at a time. After he completes then only we can give access to some one else.
    And also while Using EJB's Using syncronized DAO is not preffered since EJB's are for multiple access
    So do you have any solution for the same? Currently I am using ordinary DAO and creating multiple instances in the Session Bean.
    Is there any way to Use SingleTon Pattren inside SessionBean?
    Reply
    A Singleton DAO would be valid choice when you are doing performance/throughput optimisation for read only access to dataset which you have cached for speed, but need to ensure only one copy exists for memory efficiency.One more query martin,
    How can we use it for read only access to a data set?
    For example i have a DAO which queries and returns some result sets based on some input value given by the user
    Now take a senario1: User1 supplys some input value and executes method1() and he is in the middle.
    User2 comes in and acess the same method1() with different input value
    Since it is a SingleTon Pattren The User2 will get same refrence
    So user1 will get the result set that is having the input parameters of user2. Right?????????
    So my inference is we cannot use singelton pattren for concurrent acess of the DAO.What do you say
    Please Reply Martin

  • Using singleton to store rows of data

    Hello,
    I'm working on a web project involving struts.
    I have a jsp page, action class, action form, and a session ejb.
    I'm getting rows from database.
    What I would like to do is to use SIngleton approach to store rows of data for users.
    Does anyone know how to implement that approach?
    Thank you.

    Hello,
    I'm working on a web project involving struts.
    I have a jsp page, action class, action form, and a
    session ejb.
    I'm getting rows from database.
    What I would like to do is to use SIngleton approach
    to store rows of data for users.
    Does anyone know how to implement that approach?
    This would be a very very very bad design since the singleton would be shared between ALL users of the JSP and they would therefore interfere with each other.

  • How to publish crystal report designed using SAP Add-on toolbar

    we have installed the crystal report designer V10 and the SAP add-on on the desktop.
    we have designed a formatted report in crystal report designer using an existing BW report that was created using Bex query designer. After this we saved the crystal report back in BW to a role.
    We have not published the report to crystal enterprise server, since the connection to same is not in place.
    We would like to know how to publish this report in Enterprise portal ?
    Can we bypass publishing the report to crystal enterprise server and publish the report on browser or through EP ?

    hi
    Check on this help page if it can help you
    http://help.sap.com/saphelp_erp2004/helpdata/en/f1/0a569ae09411d2acb90000e829fbfe/frameset.htm
    REgards
    Alain

  • Deploying a WAR file containing .jsp and servlets (also uses JNI)

    Deploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
    We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
    Server documentation on deploying such files.
    This is how we went about it:
    1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
    Server.
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
    and
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
    (We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
    service packs)
    From browser, open http://yourserver:8888/
    Click on Select a Server:Manage
    Click on Virtual Server Class
    Click on https-yourserver
    Click on the Web Applications Tab
    Then, click on Deploy Web Application
    Enter the following -
    WAR File On: Local
    WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Application URI: /jakarta
    Installation Directory: c:\iPlanet\examples\jakarta-examples
    By clicking on OK it deployed the application.
    I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
    Edit     /jakarta     c:/iPlanet/examples/jakarta-examples
    Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
    - [images]
    - [jsp]
    - index.html
    - [servlets]
    - [META-INF]
    - [WEB-INF]
    - [classes]
    - [tlds]
    - web.xml
    - index.html
    I restarted the server and accessed it using the following URL from my IE browser:
    http://yourserver/jakarta/index.html
    Then I clicked on the JSP Examples and tried some JSP examples.
    b) Alternatively, you can also deploy the same example from the command-line.
    Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
    wdeploy deploy      -u /jakarta
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\jakarta-examples
              C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Restart the web server (I don't think you have to restart, but .. might as well).
    2)Deploy your web-application
    My Foo.war has the following structure.
    You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
    in your PATH)
    Foo.war
    - [META-INF]
    - [WEB-INF]
    - web.xml
    - [classes]
    - Bar.class
    - MoServlet.class
    - [lib]
    - ThirdParty.jar
    - [natlib]
    - extlib.dll
    - foo.jsp
    Here is our application scenario:
    foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
    ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
    Now to deploy it, do the following:
    (a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
    JSP compile error).
    <%@page language="java" import="Bar" contentType="text/html"%>
    (b) Check web.xml (for Servlets)
    Within web.xml, make sure you have the following mappings:
    <servlet>
    <servlet-name> MoLink </servlet-name>
    <servlet-class> MoServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> MoLink </servlet-name>
    <url-pattern> /servlet/Mo </url-pattern>
    </servlet-mapping>
    (c) Deploy the application
    Using command line:
    wdeploy deploy      -u /foo
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\foo-dir
              Foo.war
    (d) Change web-apps.xml file (for picking up ThirdParty.jar)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    You should see something similar to following after successful deployment.
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
    Change it to look like following to pick up the ThirdParty.jar
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
    <class-loader reload-interval="300"
              classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
              delegate="false"/>
    </web-app>
    (e) Change jvm12.conf file (for JNI)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    Add or uncomment the following lines:
    #optional - just helps with instrumenting the jsp and servlet code
    jvm.include.CLASSPATH=1
    jvm.enableDebug=1
    nes.jsp.enabledebug=1
    jvm.trace=7
    jvm.verboseMode=1
    #required for JNI
    java.compiler=NONE
    jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
    jvm.option=-Xrs
    jvm.option=-Xnoagent
    # not sure if this is needed for iPlanet web server
    jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
    (f) Change magnus.conf file (for JNI)
    We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
    iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
    in Path, it didn't work.
    Change Extrapath directive:
    ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    to
    ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    (g) Apply changes from the Web Server Administration Console and Restart the web server.
    You should be able to see the behaviour that you want from your application.
    http://yourserver/foo/foo.jsp
    Hope this was helpful!!!
    Sonu

    Deploying a WAR file containing .jsp and servlets (also uses JNI) on Windows 2000
    We had problems making it initially work on Sun ONE Web Server 6.0 Service Pack 1 because of lack of good iPlanet Web
    Server documentation on deploying such files.
    This is how we went about it:
    1) Make one of the servlet and JSP (must call another Java Class) web application (.war) examples work with iPlanet Web
    Server.
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\HelloWorld\HelloWorld.war
    and
    C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    a) Go to your Web Server Administration to deploy the application using GUI Web Application Deploy.
    (We usually use command line, we experienced some issues with the GUI version, but maybe it is fixed in the new Web Server
    service packs)
    From browser, open http://yourserver:8888/
    Click on Select a Server:Manage
    Click on Virtual Server Class
    Click on https-yourserver
    Click on the Web Applications Tab
    Then, click on Deploy Web Application
    Enter the following -
    WAR File On: Local
    WAR File Path: C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Application URI: /jakarta
    Installation Directory: c:\iPlanet\examples\jakarta-examples
    By clicking on OK it deployed the application.
    I can verify that it is deployed by selecting "Edit Web Applications" and I see the following entry:
    Edit     /jakarta     c:/iPlanet/examples/jakarta-examples
    Also, c:/iPlanet/examples/jakarta-examples should have the similar following directory structure ..
    - [images]
    - [jsp]
    - index.html
    - [servlets]
    - [META-INF]
    - [WEB-INF]
    - [classes]
    - [tlds]
    - web.xml
    - index.html
    I restarted the server and accessed it using the following URL from my IE browser:
    http://yourserver/jakarta/index.html
    Then I clicked on the JSP Examples and tried some JSP examples.
    b) Alternatively, you can also deploy the same example from the command-line.
    Make sure C:\iPlanet\Servers\bin\https\httpadmin\bin\ is in your path
    wdeploy deploy      -u /jakarta
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\jakarta-examples
              C:\iPlanet\Servers\plugins\servlets\examples\web-apps\jakarta-examples\jarkarta-examples.war
    Restart the web server (I don't think you have to restart, but .. might as well).
    2)Deploy your web-application
    My Foo.war has the following structure.
    You can use jar tf Foo.war to look at the file contents from command line (assuming you have JDK installed and the bin is
    in your PATH)
    Foo.war
    - [META-INF]
    - [WEB-INF]
    - web.xml
    - [classes]
    - Bar.class
    - MoServlet.class
    - [lib]
    - ThirdParty.jar
    - [natlib]
    - extlib.dll
    - foo.jsp
    Here is our application scenario:
    foo.jsp uses a class call Bar (it is not in any package). The Bar java class uses classes from ThirdParty.jar. The
    ThirdParty.jar in turn uses JNI to load library extlib.dll. foo.jsp also calls /servlet/Mo as well.
    Now to deploy it, do the following:
    (a) Make sure that within foo.jsp, you import the Bar class ( I don't know why you have to do it, but if you don't you get
    JSP compile error).
    <%@page language="java" import="Bar" contentType="text/html"%>
    (b) Check web.xml (for Servlets)
    Within web.xml, make sure you have the following mappings:
    <servlet>
    <servlet-name> MoLink </servlet-name>
    <servlet-class> MoServlet </servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name> MoLink </servlet-name>
    <url-pattern> /servlet/Mo </url-pattern>
    </servlet-mapping>
    (c) Deploy the application
    Using command line:
    wdeploy deploy      -u /foo
              -i yourserver
              -v https-yourserver
              -d c:\iplanet\examples\foo-dir
              Foo.war
    (d) Change web-apps.xml file (for picking up ThirdParty.jar)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    You should see something similar to following after successful deployment.
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true"/>
    Change it to look like following to pick up the ThirdParty.jar
    <web-app uri="/foo" dir="C:\iPlanet\examples\foo-dir" enable="true">
    <class-loader reload-interval="300"
              classpath="C:/iPlanet/examples/foo-dir/WEB-INF/lib/ThirdParty.jar"
              delegate="false"/>
    </web-app>
    (e) Change jvm12.conf file (for JNI)
    It is located in
    C:\iPlanet\Servers\https-yourserver\config
    Add or uncomment the following lines:
    #optional - just helps with instrumenting the jsp and servlet code
    jvm.include.CLASSPATH=1
    jvm.enableDebug=1
    nes.jsp.enabledebug=1
    jvm.trace=7
    jvm.verboseMode=1
    #required for JNI
    java.compiler=NONE
    jvm.classpath=.;C:\JDK1.3.1\lib\tools.jar;C:/iPlanet/Servers/plugins/servlets/examples/legacy/beans.10/SDKBeans10.jar;
    jvm.option=-Xrs
    jvm.option=-Xnoagent
    # not sure if this is needed for iPlanet web server
    jvm.option=-Djava.library.path=C:/iPlanet/examples/foo-dir/natlib/ -Djava.compiler=NONE
    (f) Change magnus.conf file (for JNI)
    We HAD to change this file in order for ThirdParty.jar file to pick up the native C++ code using JNI. Apparently, the
    iPlanet Web Server doesn't pick the Environment Variable Path. Because when we had the directory containing the DLL just
    in Path, it didn't work.
    Change Extrapath directive:
    ExtraPath C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    to
    ExtraPath c:/iPlanet/examples/foo-dir/natlib;C:/iPlanet/Servers/bin/https/bin;${NSES_JRE_RUNTIME_LIBPATH}
    (g) Apply changes from the Web Server Administration Console and Restart the web server.
    You should be able to see the behaviour that you want from your application.
    http://yourserver/foo/foo.jsp
    Hope this was helpful!!!
    Sonu

  • Cannot login to App designer using PS id while able to login in data mover.

    Hi,
    I am installing peopletool 8.50 (HRMS). I ran all the sql scripts successfully. Ran the DMS script as well for demo database.
    When I am trying to login in App designer using PS/PS i'm getting the following error..
    File: SQL Access ManagerSQL error. Stmt #: 2 Error Position: 0 Return: 404 - ORA-01017: invalid username/password; logon denied
    while I am able to login in data mover in boot strap. Can anybody pls help me out?

    yes I am using Oracle 11g.
    and man.. thanks a lot for your help. that was really awesome post :-)
    People do say true.. here only I can find the GODs of Oracle.
    Thanks Again
    Gaurav
    Edited by: Gaurav_laconic on Mar 12, 2013 6:13 PM

  • Combine two reports in query designer using key figure with sap exit

    Hi experts,
    i want to combine two reports in query designer using key figure with sap exit
    in the report 1 key figure calculation based on the open on key date(0P_DATE_OPEN)
    to calculate due and not due in two columns
    in report 2 key figure calculate in the time zones using given in variable Grid Width (0DPM_BV0) like due in 1 to 30 days, 31 to 60 days...the due amount based on the open on key date(0P_DATE_OPEN)
    to calculate in 1-30, 31-60, 61-90, 91-120, 121-150 and >150 days in 6 columns
    now i have requirement like this
    not due, 1-30, 31-60, >60, due,1-30, 31-60, >60 in 8 columns
    or
    not due, due, 1-30, 31-60, 61-90, 91-120, 121-150 and >150 in 8 col
    thank you

    Hi Dirk,
    you perhaps know my requirement,
    for the management to make used in one report,
    we have in reporting finacials Ehp3.
    Vendor Due Date Analysis - which show due, not due
    Vendor Overdue Analysis - show only due and analysis in time grid frame
    i want to combine in one report that show NOT DUE, DUE, DUE time frames in grid.
    krish...

  • I think to bye imac for graphic design use purpose. kindly guide me. Is iMac best for me ?

    i think to bye imac for graphic design use purpose. kindly guide me. Is iMac best for me ?

    Hello artistsagar,
    The word best is always subjective.   It is all a question of your needs, your working practice, your available space; I could go on.
    A Mac (probably a 27"one) may well be perfect.  Good size screen, easily understood basic functions and a huge number of recommended programs.   Just Google Mac graphic design to see what is available.

  • BOXI3.0 Universe Design using view or query in SQL

    Hi. Alias here.
    I would like to know what are the effect to the BOXI3.0 or SQL performance if:
    1. We are using view or query in creating the universe?
    2. Is it the correct way of creating the universe only from tables?
    3. If need to do combination between tables and views?
    Hope you all can reply to this matter.
    Regards,
    Alias

    Hi Alias,
    Designer has the capability to import tables and views you cna use in the design of the universe. Furthermore, you can also create a derived table in the universe - in simple terms it is much like a view, but the code is in the universe availble to the universe designer.
    With all this available to you, it is pretty much up to you how you want to tackle the design. I would say first prise is using the physical tables in the databse, then move to using a view and if there are certain restrictions on the designer, use the derived tables.
    Remeber this, at the end of the day, any SQL code generated or used is passed down to the database to be processed, may it be the query from the universe directly on the tables or by means of the views or derived tables - the database server will need to crunch through it all - and this is what will determine your performance.
    Regards
    Jacques

  • How to use report designer using bex analyser  give screenshots  details

    how to use report designer using bex analyser  give screenshots  details

    Hi,
    As per my understanding you want to see Query Designer when you execute the query in BEx Analyzer.
    When you launch BEx analyzer,you should be able to see  new tab of "Business Explorer" in your Toolbar.
    So,when you execute the query in BEx analyzer,in order to goto query designer screen,click on Tab "Business Explorer",select option "Change Query" and then select the option "ChangeQuery (Global Definition)".
    It will open the query designer in which you can modify the query and save it.
    Regards,
    Nilima

  • How  to use report designer   using bex analyser ineed screeenshots  steps

    how  to use report designer   using bex analyser ineed screeenshots  steps

    Please try to search and stop asking for all types of screen shots. Thanks!

  • Website Design Using Adobe Flash

    Hi everybody,
    I need some help from anyone that expert in website design using adobe flash player.
    Please send me a PM.
    Thank you
    Jarlabs

    Would you mind reposting this question over on the Flash Professional forums?  This forum is primarily for end users, the Pro forums will get you in touch with a wider developer audience.

  • 'Change your password' error when log to designer using SAP Authentication

    Hi All,
    Here is the scenario. I want to create a universe on BW.
    1. I try to log into designer using SAP authentication (by choosing SAP as the authentication option)
    2. In the system name its the name of the CMS
    3. The username and password that I entered were for my SAP system. (Yes, my SAP role is already present in CMC)
    4. After I entered, I got a message saying ' You must change your password to continue. If you do not change your password, your account might get disabled'.
    5. I am prompted with dialogue box to change my password.
    6. After I enter a new password (fairly complicated), it gives an error Failed to change password/ Details : [repo_proxy 15]. Sessionfacade:: changePassword - User password has not been updated (Incorrect password).
    I know that's not the case because I am able to log into SAP GUI and into CMC using my SAP credentials.
    Any advice please ? Why is this happening in designer ?

    Hi,
    Your issue may be fixed in FP1.8 with the following reference:
    ADAPT01229385
    Description:
    +If an Enterprise alias is created for a SAP user accounts in the Central Management Console (CMC), and set to change their+
    +passwords at the next log on, the SAP users may be unable to log on to applications with their SAP credentials.+
    +This problem happens even after the Enterprise alias is removed from the SAP user accounts in the CMC.+
    I hope this helps.
    regards,
    Henry

  • I want to display the website which i have designed using jsp in telugu....

    Hi,
    I want to display the website which i have designed using jsp,mysql in telugu.I have searched a number of articles but couldn't get sufficient information.I read articles on internationalise jsp based websites but they were about converting in other languages rather than indic languages.
    Could anyone let me know the procedure to convert it into indic languages.What all are required.
    Thanks.

    (Please keep the subject line to a short descriptive sentence. Don't put your entire question there.)
    LabVIEW can communicate via serial port. If the microcontroller listens to serial data, there must be a certain command to light a LED connected to a certain port. All you need is to check the manual to find out what the serial data needs to be.
    LabVIEW Champion . Do more with less code and in less time .

  • How to run servlet by using main?

    How can I use main to run servlet?
    I cannot put request and response object into doGet(request, response) method
    I want this because I want to run this servlet daily and I plan to put it in cron job
    Calvin

    Hi
    Perhaps you cannot run servlet without using browser. But you can make that program as an application in order to run in Dos or Unix shell.
    But still you can run servlet without using browser How?
    You can debug servlets with the same jdb commands you use to debug an applet or an application. The JavaTM Servlet Development Kit (JSDK) provides a standalone program
    called servletrunner that lets you run a servlet without a web browser. On most systems, this program simply runs the java sun.servlet.http.HttpServer command. You
    can, therefore, start a jdb session with the HttpServer class.
    A key point to remember when debugging servlets is that Java Web server and servletrunner achieve servlet loading and unloading by not including the servlets directory on
    the CLASSPATH. This means the servlets are loaded using a custom classloader and not the default system classloader.
    Running servletrunner in Debug Mode
    Running Java Web ServerTM in Debug Mode
    Running servletrunner in Debug Mode
    In this example, the servlets examples directory is included on the CLASSPATH. You can configure the CLASSPATH for debug mode as follows:
    Unix
    $ export CLASSPATH=./lib/jsdk.jar:./examples:$CLASSPATH
    Windows
    $ set CLASSPATH=lib\jsdk.jar;examples;%classpath%
    To start the servletrunner program you can either run the supplied startup script called servletrunner or just supply the servletrunner classes as a parameter to jdb. This
    example uses the parameter to servletrunner.
    $ jdb sun.servlet.http.HttpServer
    Initializing jdb...
    0xee2fa2f8:class(sun.servlet.http.HttpServer)
    > stop in SnoopServlet.doGet
    Breakpoint set in SnoopServlet.doGet
    > run
    run sun.servlet.http.HttpServer
    running ...
    main[1] servletrunner starting with settings:
    port = 8080
    backlog = 50
    max handlers = 100
    timeout = 5000
    servlet dir = ./examples
    document dir = ./examples
    servlet propfile = ./examples/servlet.properties
    To run SnoopServlet in debug mode, enter the following URL in a browser where yourmachine is the machine where you started servlet runner and 8080 is the port number
    displayed in the settings output.
    http://yourmachine:8080/servlet/SnoopServlet
    In this example jdb stops at the first line of the servlet's doGet method. The browser will wait for a response from your servlet until a timeout is reached.
    main[1] SnoopServlet: init
    Breakpoint hit: SnoopServlet.doGet (SnoopServlet:45)
    Thread-105[1]
    We can use the list command to work out where jdb has stopped in the source.
    Thread-105[1] list
    41 throws ServletException, IOException
    42 {
    43 PrintWriter out;
    44
    45 => res.setContentType("text/html");
    46 out = res.getWriter ();
    47
    48 out.println("<html>");
    49 out.println("<head>
    <title>Snoop Servlet
    </title></head>");
    Thread-105[1]
    The servlet can continue using the cont command.
    Thread-105[1] cont
    Running Java Web Server in Debug Mode
    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
    servletrunner, then the other option is to run the Java Web server in debug mode.
    To do this add the -debug flag for the first parameter after the java program. For example in the script bin/js 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 java_g instead of java.
    Before:
    exec $JAVA $THREADS $JITCOMPILER $COMPILER $MS $MX \
    After:
    exec $JAVA -debug $THREADS $JITCOMPILER
    $COMPILER $MS $MX \
    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.
    jdb -host localhost -password <the agent password>
    The servlets are loaded by a separate classloader if they are contained in the servlets directory, which is not on the CLASSPATH used when starting the Java Web server.
    Unfortunately, when debugging remotely with jdb, you cannot control the custom classloader and request it to load the servlet, so you have to either include the servlets
    directory on the CLASSPATH for debugging or load the servlet by requesting it through a web browser and then placing a breakpoint once the servlet has run.
    In this next example, the jdc.WebServer.PasswordServlet is included on the CLASSPATH when Java Web server starts. The example sets a breakpoint to stop in the service
    method of this servlet, which is the main processing method of this servlet.
    The Java Web Server standard output produces this message, which lets you proceed with the remote jdb session:
    Agent password=3yg23k
    $ jdb -host localhost -password 3yg23k
    Initializing jdb...
    > stop in jdc.WebServer.PasswordServlet:service
    Breakpoint set in jdc.WebServer.PasswordServlet.service
    > stop
    Current breakpoints set:
    jdc.WebServer.PasswordServlet:111
    The second stop 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
    <FORM METHOD="post" action="/servlet/PasswordServlet">
    <INPUT TYPE=TEXT SIZE=15 Name="user" Value="">
    <INPUT TYPE=SUBMIT Name="Submit" Value="Submit">
    </FORM>
    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 Remote Debugging
    section.
    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)
    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 catch command allows you to trap all these exceptions.
    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)
    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 cont to allow the web server
    to proceed. To clear this trap use the ignore command.
    webpageservice Handler[1] ignore java.io.IOException
    webpageservice Handler[1] catch
    webpageservice Handler[1]
    I hope this will help you.
    Thanks
    Bakrudeen

Maybe you are looking for

  • How can i get TIGHT and FAT TOMS ?

    Hi, i am discovering the pleasure of EzDrummer on Logic w/ the multichannel mode. You can really get olmost any kind of genre-sound out of it, amazing. but i am having some "problems" w/ the toms. They sound good, open and natural ..but even too much

  • My iPhone and iPad air 2 won't share messages

    MMy iPhone and iPad air 2 won't share messages. I can't find where to enter my phone #

  • Java3D SDN's HelloUniverse1 Help

    Hello, Im trying to learn Java3D, Im very new to Java as it is... im using SDN's HelloUniverse1 Example but am having real difficulties when trying to run it. Im getting this error: renderer.doWork(long) Line:776 renderer(J3dThread).run() Line: 250 A

  • CAN I CHANGE THE BACK COVER OF IPHONE 5

    I have a small scratch(hollow) near the on/off button of my black iphone 5. Can I change /buy a new back cover from Apple ?

  • Field symbols in SMARTFORMS

    Hi all,     I have to show the Item wise amount in a Purchase order thro SMARTFORM. I don't have any problem when the purchase order has currency 'INR'. But when the Purchase order contains foreign currency, I have to show the amount upto 4 decimals.