Running Servlet Using ServletRunner(Midlet Connectivity)

Hi I've made a program that connects a midlet to a servlet for DB connectivity.But when i compile the servlet class it gives error Http servlet not found.I want to ask in which folder of (JSDK2.0) should i keep my servlet file so as to compile it & in which folder should the class file be placed so as to run on the localhost.Please help me as its urgently needed for my project.Thanks.......

Usually to manage servlet you have to create a WEB-INF directory where to put your web.xml file and a 'classes' sub directory where to put the servlet (.java & .class).

Similar Messages

  • Connecting a servlet using a midlet

    Hi,
    I am trying to connect to a servlet using a Midlet. The servlet is running fine on Apache Tomcat and I m able to build the MIDlet using J2MEWTK . But when I execute the Midlet on an emulator it shows me some code of html page of which the important line which might give u some hint is :
    the requested resource (/hitservlet) is not available.
    I wrote the code of HitServlet and Hitmidlet using a pdf on net....Do I need to install something else for executing this? I dont understand where is the problem. Should I post the codes? Is it something related to aliases...as indicated by some some tutorial...if so plss elaborate on it..
    If anybdy has any idea ...plss help me get out of this problem...
    Thanx
    Smeeta

    Have you added the URL of the Servlet into the J2ME application?
    Settings -> UserDefined Tab
    Thinks its
    HitMIDlet.URL and its value should be the URL of the Servlet

  • Problem running servlet using PJA tools

    Hi
    I am trying to run the TeksSurveyPie servlet from the PJA Package.But everytime i run it says
    Internal error: Unexpected error condition thrown (java.lang.NoClassDefFoundError: TeksSurveyPie (wrong name: com/eteks/servlet/TeksSurveyPie),TeksSurveyPie (wrong name: com/eteks/servlet/TeksSurveyPie)), stack: java.lang.NoClassDefFoundError: TeksSurveyPie (wrong name: com/eteks/servlet/TeksSurveyPie)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:495)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:110)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
    at java.net.URLClassLoader.access$1(URLClassLoader.java:217)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:192)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:300)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:290)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:256)
    at java.lang.ClassLoader.findSystemClass(ClassLoader.java:629)
    at com.iplanet.server.http.servlet.NSServletLoader.findClass(NSServletLoader.java:152)
    at com.iplanet.server.http.servlet.NSServletLoader.loadClass(NSServletLoader.java:108)
    at com.iplanet.server.http.servlet.NSServletEntity.load(NSServletEntity.java:337)
    at com.iplanet.server.http.servlet.NSServletEntity.update(NSServletEntity.java:173)
    at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:427)
    I am tryin to access the servlet like this
    https://avenger/servlet/TeksSurveyPie?survey=Yes
    Pls tell me where i am going wrong...????Its preety urgent ....
    thanks
    prabhu

    the servlet is as below for reference .....
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletException;
    import javax.servlet.ServletConfig;
    import javax.servlet.UnavailableException;
    import java.io.IOException;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.OutputStream;
    import java.util.Properties;
    import java.util.Vector;
    import java.util.Enumeration;
    import java.util.Hashtable;
    import java.util.StringTokenizer;
    import java.awt.Graphics;
    import java.awt.Color;
    import java.awt.Frame;
    import java.awt.AWTError;
    import java.awt.Image;
    import java.awt.image.FilteredImageSource;
    import Acme.JPM.Encoders.GifEncoder;
    import com.eteks.filter.Web216ColorsFilter;
    import com.eteks.awt.servlet.PJAServlet;
    * This servlet manages in a simple way a dynamic survey and returns the pie of the survey.
    * It can be called in either ways :
    * <UL><LI><code>.../servlet/com.eteks.servlet.TeksSurveyPie?survey=mySurvey&answer=myAnswer</code>
    * adds the answer <code>myAnswer</code> to the survey <code>mySurvey</code>,
    * and then returns the pie of the current state of <code>mySurvey</code>.
    * <LI><code>.../servlet/com.eteks.servlet.TeksSurveyPie?survey=mySurvey</code>
    * simply returns the pie of the current state of <code>mySurvey</code>.</UL>
    * <P>To be platform independant, the servlet uses <code>com.eteks.awt.servlet.PJAServlet</code> as super class,
    * to have at disposal an image into which graphics operation can be performed.<BR>
    * <code>com.eteks.awt.PJAServlet</code> class and depending classes of <code>com.eteks.awt</code> packages
    * must be in the servlet engine classpath, and at least one .pjaf font file (Pure Java AWT Font) must exist
    * in the user directory or in the directory set in the <code>java.awt.fonts</code> system property,
    * if JVM version <= 1.1.<BR>
    public class TeksSurveyPie extends PJAServlet
    Properties surveysParam = new Properties ();
    String fontsDir = ""; // Default value for "java.awt.fonts" .pjaf fonts directory initParameter
    String surveysFile = fontsDir + File.separator + "survey.txt"; // Default value for survey file initParameter
    // Colors used to fill the pie
    final Color colors [] = {Color.blue,
    Color.green,
    Color.red,
    Color.cyan,
    Color.magenta,
    Color.gray,
    Color.yellow,
    Color.pink,
    Color.orange,
    Color.white};
    final Color penColor = Color.black;
    public void initPJA (ServletConfig config) throws ServletException
    // Store the ServletConfig object and log the initialization
    super.initPJA (config);
    // Retrieves surveys file path
    String param = getInitParameter ("surveysFile");
    if (param != null)
    surveysFile = param;
    param = getInitParameter ("fontsDir");
    if (param != null)
    fontsDir = param;
    FileInputStream in = null;
    try
    in = new FileInputStream (surveysFile);
    surveysParam.load (in);
    catch (IOException e)
    { } // Empty properties
    finally
    try
    if (in != null)
    in.close ();
    catch (IOException ex)
    public void destroyPJA ()
    try
    surveysParam.save (new FileOutputStream (surveysFile), "Survey file");
    catch (IOException e)
    { } // Properties can't be saved
    public String getFontsPath ()
    return super.getFontsPath () + File.pathSeparator
    + fontsDir;
    public void doPostPJA (HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException
    doGetPJA (request, response);
    public void doGetPJA (HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException
    String survey = request.getParameter ("survey"); // Survey name
    String answer = request.getParameter ("answer"); // Proposed answer
    String paramWidth = request.getParameter ("width");
    String paramHeight = request.getParameter ("height");
    int width = paramWidth == null ? 200 : Integer.parseInt (paramWidth);
    int height = paramHeight == null ? 100 : Integer.parseInt (paramHeight);
    // v1.1 : Changed code to enable image creation
    // even if PJAToolkit couldn't be loaded by Toolkit.getDefaultToolkit ()
    Image image = createImage (width, height);
    if (survey == null)
    survey = "";
    if (answer != null)
    String key = survey + "_" + answer;
    String value = surveysParam.getProperty (key);
    if (value != null)
    // If the answer already exists, increase its value
    surveysParam.put (key, String.valueOf (Integer.parseInt (value) + 1));
    else
    String surveyAnswers = surveysParam.getProperty (survey);
    // Add this answer to the other ones
    if (surveyAnswers == null)
    surveysParam.put (survey, answer);
    else
    surveysParam.put (survey, surveyAnswers + "," + answer);
    surveysParam.put (key, "1");
    Hashtable answers = new Hashtable ();
    Vector sortedAnswers = new Vector ();
    synchronized (surveysParam)
    String surveyAnswers = surveysParam.getProperty (survey);
    if (surveyAnswers != null)
    for (StringTokenizer tokens = new StringTokenizer (surveyAnswers, ",");
    tokens.hasMoreTokens (); )
    String token = tokens.nextToken ();
    int answerCount = Integer.parseInt (surveysParam.getProperty (survey + "_" + token));
    answers.put (token, new Integer (answerCount));
    // Seek the good place to insert this element
    int i;
    for (i = 0; i < sortedAnswers.size (); i++)
    if (answerCount > ((Integer)answers.get (sortedAnswers.elementAt (i))).intValue ())
    break;
    sortedAnswers.insertElementAt (token, i);
    // Compute the pies of the survey
    drawSurveyPies (image, answers, sortedAnswers, width, height);
    // Send generated image
    sendGIFImage (image, response);
    * Generates a GIF image on the response stream from image.
    public void sendGIFImage (Image image, HttpServletResponse response) throws ServletException, IOException
    // Set content type and other response header fields first
    response.setContentType("image/gif");
    // Then write the data of the response
    OutputStream out = response.getOutputStream ();
    try
    new GifEncoder (image, out).encode ();
    catch (IOException e)
    // GifEncoder may throw an IOException because "too many colors for a GIF" (> 256)
    // were found in the image
    // Reduce the number of colors in that case with Web216ColorsFilter basic filter
    new GifEncoder (new FilteredImageSource (image.getSource (),
    new Web216ColorsFilter ()),
    out).encode ();
    out.flush ();
    private void drawSurveyPies (Image image,
    Hashtable answers,
    Vector sortedAnswers,
    int width,
    int height)
    Graphics gc = image.getGraphics ();
    // Draw a shadow
    gc.setColor (penColor);
    gc.fillOval (1, 1, height - 3, height - 3);
    gc.fillOval (2, 2, height - 3, height - 3);
    // Compute the sum of all values
    int sum = 0;
    for (Enumeration e = answers.elements ();
    e.hasMoreElements (); )
    sum += ((Integer)e.nextElement ()).intValue ();
    for (int accum = 0, i = 0, deltaY = 0; i < sortedAnswers.size (); i++, deltaY += 15)
    int answerValue = ((Integer)answers.get (sortedAnswers.elementAt (i))).intValue ();
    int startAngle = accum * 360 / sum;
    int angle = answerValue * 360 / sum;
    // Fill the anwser pie
    gc.setColor (colors [i % colors.length]);
    gc.fillArc (0, 0, height - 3, height - 3, startAngle, angle);
    // Draw a separating line
    gc.setColor (penColor);
    gc.drawLine ((height - 3) / 2, (height - 3) / 2,
    (int)((height - 3) / 2. * (1 + Math.cos (startAngle / 180. * Math.PI)) + 0.5),
    (int)((height - 3) / 2. * (1 - Math.sin (startAngle / 180. * Math.PI)) + 0.5));
    accum += answerValue;
    if (deltaY + 15 < height)
    // Add a comment
    gc.setColor (colors [i % colors.length]);
    gc.fillRect (height + 6, deltaY + 1, 13, 10);
    gc.setColor (penColor);
    gc.drawRect (height + 5, deltaY, 14, 11);
    // Draw is done with default font
    gc.drawString (String.valueOf (100 * answerValue / sum) + "% " + (String)sortedAnswers.elementAt (i),
    height + 22, deltaY + 9);
    gc.drawLine ((height - 3) / 2, (height - 3) / 2, height - 3, (height - 3) / 2);
    // Draw a surrounding oval
    gc.drawOval (0, 0, height - 3, height - 3);
    Thx
    prabhu

  • HTTP vs HTTPS when running Xcelsius using Netweaver BI Connection

    We have created a dashboard in Xcelsius using the Netweaver BI connection to get the data from SAP BW system. The xcelsius file is saved on the BW server. The dashboard is made available to the users using a iview in SAP portal using the iview template for BEx Web Template 7.0. and query string "DASHBOARD=Z_XCELSIUS_FILENAME". Our Portal and BW systems are configured to use HTTPS.
    When the users access the dashboard, standard security information dialog box is displayed warning users that the page contains secure and nonsecure items requiring them to click on Yes to go forward. The security information box is displayed because of a HTTP call to the Adobe macromedia for downloading flash player if needed.
    We would like to avoid the security information box. Any ideas would be greatly appreciated. We don't have the option to use HTTP instead of HTTPS on the portal and BW servers.

    Hi,
    Is this issue resolved? I am getting the same error "Fail to retrieve the logon ticket, please contact the administrator" in      Xcelsius 2008. I am using the SAP GUI 7.0 Patch level 15.
    Please help me how to resolve the error.
    Regards,
    Raj.
    Edited by: Raj.kumar on Aug 15, 2010 6:45 PM

  • Running servlet using Tomcat

    I have installed tomcat4.1.12..Ihave set up the environment variables also.
    set JAVA_HOME=C:\j2sdk1.4.0_02;
    set CATALINA_HOME=C:\jakarta-tomcat-4.1.12;
    PATH C:\WINDOWS;C:\WINDOWS\COMMAND;%JAVA_HOME%\bin;%JAVA_HOME%\lib;%CATALINA_HOME%\jakarta-tomcat-4.1.12\common\lib\servlet.jar;
    When i try to start tomcat its showing the following error .
    CATALINA_HOME ENVIRONMENT IS NOT DEFINED PROPERLY.
    Can anyone please tell me whats going on..?
    thanks in advance
    iby

    set JAVA_HOME=C:\j2sdk1.4.0_02;
    set CATALINA_HOME=C:\jakarta-tomcat-4.1.12;what are those semicolons doing there? Win2K (guessing from C:\ and backslashes) actually takes them as part of the environment variable. And your directories are probably not named "C:\j2sdk1.4.0_02;" and "C:\jakarta-tomcat-4.1.12;"???

  • 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

  • Use jdbc to connect servlet to oracle 8.1.6 database on win2k

    The code is below:
    package moreservlets;
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    /** Simple servlet used to test JDBC connection. */
    public class TitleQueries extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Connecting to Database";
    DriverManager.registerDriver (new
    oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@pc840:1521:orcl", "scott", "tiger");
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery
    ("select ename from emp");
    while (rset.next()) {
    String name = rset.getString("ename");
    out.println(ServletUtilities.headWithTitle(title) +
    "<body bgcolor=\"#FDF5E6\">\n" +
    "<h1 align=\"center\">" + name + "</h1>\n" +
    "</body></html>");
    CLASSPATH=.;C:\J2ee;C:\j2sdkee1.3.1\lib\cloudscape;C:\Program Files\Apache Tomcat 4.0\common\lib\servlet.jar;C:\Oracle\Ora81\orb\classes\yoj.jar;C:\Oracle\Ora81\orb\classes\share.zip
    My code cannot find the JDBC driver. Any suggestions?
    Thanks.
    I get the following errors:
    C:\J2ee\moreservlets>javac -d "C:\Program Files\Apache Tomcat 4.0\webapps\ROOT\
    EB-INF\classes" TitleQueries.java
    TitleQueries.java:19: package oracle.jdbc.driver does not exist
    oracle.jdbc.driver.OracleDriver());
    ^
    TitleQueries.java:31: cannot resolve symbol
    symbol : variable name
    location: class moreservlets.TitleQueries
    "<h1 align=\"center\">" + name + "</h1>\n" +
    ^
    2 errors

    I changed my classpath variable and my servlet
    compiles okay with the:
    "import oracle.jdbc.driver.*" statement.
    However, I still get the following error.
    Why can't it find the jdbc driver, since it finds the
    import statement?
    Apache Tomcat/4.0.3
    Error loading driver: java.lang.ClassNotFoundException: oracle.jdbc.driver.Oracl
    eDriver
    WebappClassLoader: Resource '/WEB-INF/classes/moreservlets/ServletUtilities.cl
    ass' was modified; Date is now: Tue Jul 02 09:57:26 CDT 2002 Was: Tue Jul 02 09:
    37:20 CDT 2002
    Error loading driver: java.lang.ClassNotFoundException: oracle.jdbc.driver.Oracl
    eDriver
    CLASSPATH=.;C:\J2ee;C:\j2sdkee1.3.1\lib\cloudscape\RmiJdbc;C:\Program Files\Apache Tomcat 4.0\common\lib\servlet.jar;C:\Oracle\Ora81\jdbc\lib\classes12.zip;C:\Oracle\Ora81\orb\classes\yoj.jar;C:\Program Files\Oracle\JDeveloper 3.2.3\jdbc\lib\oracle8.1.7\classes12.zip;C:\Oracle\Ora81\orb\classes\share.zip
    //code begins here
    package moreservlets;
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import oracle.jdbc.driver.*;
    public class TitleQueries extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@pc840:1521:orcl", "scott", "tiger");
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery
    ("select * from emp");
    out.println(ServletUtilities.headWithTitle(title) +
    "<body bgcolor=\"#FDF5E6\">");
    while (rset.next()) {
    out.println("<h1 align=\"center\">"
    + rset.getString("ename") + "</h1>\n");
    out.println("</body></html>");
    catch(ClassNotFoundException cnfe) {
    System.err.println("Error loading driver: " + cnfe);
    catch(SQLException sqle) {
    System.err.println("Error connecting: " + sqle);
    }

  • Problem to connect to mysql from servlet using a javabean

    Hi,
    I'm new here and beginner on java to.
    I have problem to connect to MySql database, by a connection javabean.
    It's the following: a HTML page calls a servlet and this servlet imports the package connection javabean.
    It has no problem when I establish the connection inside the servlet, with all its methods (public and private). But i want to separate the code connection from servlet.
    Detail: there is no problem, using the javabean to connect to MS Access database.
    I put "mysql-connector-java-3.1.12-bin.jar" file inside WEB-INF/lib application and common/lib directories.
    I set the classpath:
    SET CLASSPATH=%CATALINA_HOME%\COMMON\LIB\mysql-connector-java-3.1.12-bin.jar;%CLASSPATH%
    I think that the servlet cannot create an instance of javabean, because passed by catch exception of the servlet init method.
    But I don't know why.
    Please Why?
    Below there are the fragment of errors, servlet code e javabean code.
    Thank you.
    Zovao.
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
    at CadServletFileBeanConexArq.doPost(CadServletFileBeanConexArq.java:47)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
    Note: The line 47 is calling insertIntoDB javabean method.
    ========///////////////===============
    // Here is the servlet CadServletFileBeanConexArq.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    import conJdbc.*;
    public class CadServletFileBeanConexArq extends HttpServlet {
    public ConexPed connect = null;
    private String driver = "com.mysql.jdbc.Driver";
    private String URL = "jdbc:mysql://localhost:3306/cadastro";
    public void init( ServletConfig config )
    throws ServletException
    super.init( config );
    try
    connect = new ConexPed(driver, URL, "monty", "some_pass");
    catch ( Exception e )
    e.printStackTrace();
    connect = null;
    public void doPost( HttpServletRequest req,
    HttpServletResponse res )
    throws ServletException
    boolean success = true;
    String email, nome, sobrenome, produto, valor;
    email = req.getParameter( "Email" );
    nome = req.getParameter( "Nome" );
    sobrenome = req.getParameter( "Sobrenome" );
    produto = req.getParameter( "Produto" );
    valor = req.getParameter( "Valor" );
    res.setContentType( "text/html" );
    if ( email.length() > 0 && nome.length() > 0 && sobrenome.length() > 0 && valor.length() > 0 )
    /* inserting data */
    success = connect.insertIntoDB(
    "'" + email + "','" + nome + "','" + sobrenome + "','" + produto + "'", Double.parseDouble(valor) );
    //closing connection
    public void destroy()
    connect.fecharConexao();
    =============///////////////============
    Here is the JavaBean.
    package conJdbc;
    import java.sql.*;
    public class ConexPed
    public Connection connection;
    public Statement statement;
    public ConexPed (String driver, String urlServidor, String user, String password)
    try
    Class.forName(driver);
    connection = DriverManager.getConnection(urlServidor,user,password);
    catch (ClassNotFoundException ex)
    System.out.println("N�o foi poss�vel encontrar a classe do Driver: " + driver);
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel conectar ao servidor");
    try
    statement = connection.createStatement();
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel criar a statement");
    *Inserting data to database
    public synchronized boolean insertIntoDB( String stringtoinsert, double valor)
    try
    statement.executeUpdate( "INSERT INTO pedido values (" + stringtoinsert + " , " + valor + ");" );
    catch ( Exception e ) {
    System.err.println(
    "ERROR: Problemas ao adicionar nova entrada" );
    e.printStackTrace();
    return false;
    return true;
    * Close statement.
    public void fecharStatement()
    try
    statement.close();
    catch (SQLException ex)
    ex.printStackTrace();
    * close database
    public void fecharConexao()
    try
    connection.close();
    catch (SQLException ex)
    ex.printStackTrace();
    }

    Hi,
    I'm new here and beginner on java to.
    I have problem to connect to MySql database, by a connection javabean.
    It's the following: a HTML page calls a servlet and this servlet imports the package connection javabean.
    It has no problem when I establish the connection inside the servlet, with all its methods (public and private). But i want to separate the code connection from servlet.
    Detail: there is no problem, using the javabean to connect to MS Access database.
    I put "mysql-connector-java-3.1.12-bin.jar" file inside WEB-INF/lib application and common/lib directories.
    I set the classpath:
    SET CLASSPATH=%CATALINA_HOME%\COMMON\LIB\mysql-connector-java-3.1.12-bin.jar;%CLASSPATH%
    I think that the servlet cannot create an instance of javabean, because passed by catch exception of the servlet init method.
    But I don't know why.
    Please Why?
    Below there are the fragment of errors, servlet code e javabean code.
    Thank you.
    Zovao.
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    java.lang.NullPointerException
    at CadServletFileBeanConexArq.doPost(CadServletFileBeanConexArq.java:47)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:716)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
    Note: The line 47 is calling insertIntoDB javabean method.
    ========///////////////===============
    // Here is the servlet CadServletFileBeanConexArq.java
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    import conJdbc.*;
    public class CadServletFileBeanConexArq extends HttpServlet {
    public ConexPed connect = null;
    private String driver = "com.mysql.jdbc.Driver";
    private String URL = "jdbc:mysql://localhost:3306/cadastro";
    public void init( ServletConfig config )
    throws ServletException
    super.init( config );
    try
    connect = new ConexPed(driver, URL, "monty", "some_pass");
    catch ( Exception e )
    e.printStackTrace();
    connect = null;
    public void doPost( HttpServletRequest req,
    HttpServletResponse res )
    throws ServletException
    boolean success = true;
    String email, nome, sobrenome, produto, valor;
    email = req.getParameter( "Email" );
    nome = req.getParameter( "Nome" );
    sobrenome = req.getParameter( "Sobrenome" );
    produto = req.getParameter( "Produto" );
    valor = req.getParameter( "Valor" );
    res.setContentType( "text/html" );
    if ( email.length() > 0 && nome.length() > 0 && sobrenome.length() > 0 && valor.length() > 0 )
    /* inserting data */
    success = connect.insertIntoDB(
    "'" + email + "','" + nome + "','" + sobrenome + "','" + produto + "'", Double.parseDouble(valor) );
    //closing connection
    public void destroy()
    connect.fecharConexao();
    =============///////////////============
    Here is the JavaBean.
    package conJdbc;
    import java.sql.*;
    public class ConexPed
    public Connection connection;
    public Statement statement;
    public ConexPed (String driver, String urlServidor, String user, String password)
    try
    Class.forName(driver);
    connection = DriverManager.getConnection(urlServidor,user,password);
    catch (ClassNotFoundException ex)
    System.out.println("N�o foi poss�vel encontrar a classe do Driver: " + driver);
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel conectar ao servidor");
    try
    statement = connection.createStatement();
    catch (SQLException ex)
    System.out.println("N�o foi poss�vel criar a statement");
    *Inserting data to database
    public synchronized boolean insertIntoDB( String stringtoinsert, double valor)
    try
    statement.executeUpdate( "INSERT INTO pedido values (" + stringtoinsert + " , " + valor + ");" );
    catch ( Exception e ) {
    System.err.println(
    "ERROR: Problemas ao adicionar nova entrada" );
    e.printStackTrace();
    return false;
    return true;
    * Close statement.
    public void fecharStatement()
    try
    statement.close();
    catch (SQLException ex)
    ex.printStackTrace();
    * close database
    public void fecharConexao()
    try
    connection.close();
    catch (SQLException ex)
    ex.printStackTrace();
    }

  • Unable to run Servlet program using J2EE SDK

    Hello,
    i am a newbie to all this j2ee stuff and servlets even.so the problem that i have maybe a very common one and i hope that most of you may have a fix to it...
    i use J2EE SDK to compile and run Servlet programs.I have a Servlet program with the class name defined as
    public class MyServlet extends HttpServlet ....
    the file is stored as MyServlet.java
    i set the CLASSPATH variable so that the required classes for the compilation of the program can be located.
    the program compiles without any glitches.
    However when i run the program by saying
    java MyServlet
    ( i dont think its any different to run servlet code is it?)
    i get the message
    java.lang.NoClassDefFoundException:MyServlet
    Can someone suggest a remedy?
    thank you
    -NDK

    First, I don't understand what you are trying to do. Running a servlet ?
    Servlets are ran by an application server ! (Apache Tomcat ....).
    Second, is your class in any package ?

  • How to dynamically validate users at run time using connection pools ?

    Hi Folks
    We are facing a peculiar situation . We have established connection to our
    oracle 8i database using Oracle Thin driver using conenction pooling at the weblogic
    server . We set up connection pools at the console to set up connections to thge
    oracle 8i database. However the user name and password is always static when
    we create the connection pool at the console .
    How do i dynamically validate other users using the same connection pool ??
    Eg - The connection pool at design time in the console uses user A and password
    - passA . Now at run time lets say I prompt the user for a login screen and want
    to trap the user id and apssword parameters entered by the user and use it with
    the connection pool created earlier . I tried using the below code snippet :-
    Properties props = new Properties();
    props.put("connectionPoolID", "Oracle_Thin_Driver_Pool");
    props.put("user" , userId );
    props.put("password",userPass);
    myDriver = (Driver) Class.forName("weblogic.jdbc.pool.Driver").newInstance();
    conn = myDriver.connect("jdbc:weblogic:pool", props);
    But always it connects to the database using the userid and password set in the
    console while creating the connection pool . So how i get the connection pool
    to validate my current userid and password entered through the login screen ??
    Thanks in advance
    Keith

    Hey Bob.
    So I assume you're -completely- working with built executables?  You're not going to work in the editor environment to modify your projects at all?
    If this is the case, then having a generic deployment phase at the beginning of the executable (with a "setting up hardware for your app" splash screen) isn't a bad idea -
    Check the binary on the target, ensure it matches the binary you have on the host machine (in case you ever decide to update).
    If they don't match, FTP the new file down to replace the old one.
    FTP the ni-rt.ini file, ensure the startup exe is enabled and is pointing to the correct location.  
    If it's not enabled or not pointing to the correct startup file, modify the .INI file and FTP back to the target.
    If you had to update the INI file, ask target to reboot itself.  Wait 30 seconds, and wait for target to become available again.
    Connect to the target. If you cannot connect, reboot target.  If the target comes back and you still cannot connect to the app, notify user.
    That's almost exactly how we handle installation and deployment via MAX.  
    The big assumption here is that the built executables were all built with the same version of LabVIEW Real-Time.  If not, you'd need a system replication step in there to make sure the proper version of LabVIEW is on the target before launching the built .rtexe.  
    -Danny

  • Cannot run a servlet using Tomcat. Urgent

    I have a webapplication which uses some jsp's and servlets. The jsp pages work fine when I use
    http://hostname:8080/MyWebapp/Filename.jsp
    However, when I developed a java servlet and put the class file in WEB-INF/classes directory of my web application and tried to access it.
    I got a resource not found error.
    The strange thing is that when I put the file in the web-inf/classes folder of examples webapplication (which comes with Tomcat) I am able to run the servlet using
    http://hostname:8080/examples/servlet/Class file
    I am not sure what is wrong.
    Can someone help me.
    Thanks in advance
    Vamsi.

    It's predictable. The Servlet and JSP specifications mandate that you cannot directly access resources under WEB-INF directory. You have to set up servlet mapping configuration in your web.xml to specify how to access the resources, both Servlet and JSP, there.
    When you copied your files in a demo webapp of Tomcat, the web.xml of the demo app already set up the mapping like following for you. So you could use http://hostname:8080/examples/servlet/Class to visit the servlet.
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
    The default setting since Tomcat 4.1 turned off servlet invoker in web.xml under conf directory. You can uncomment the above lines in this file to turn it on. Then you are able to visit your servlet without <servlet-mapping> configured using the following syntax,
    http://hostname:8080/<your_app_name>/servlet/<your_servlet_name>

  • I have an old PowerPC and a Macbook Pro running 10.6.7 sitting side by side. Both are using AirPort to connect to the internet wirelessly to the same router, but the old Mac connects with full bars, but the MBP struggles with only 2. Pls help, thanks!

    I have an old PowerPC running 10.4.11 and a Macbook Pro running 10.6.7 sitting side by side. Both are using AirPort to connect to the internet wirelessly to the same wireless router. The old Mac connects with full bars but the MBP struggles with only 2 bars. Pls help, thanks!

    BDAqua,
    Thanks for the response.
    Apple has used the term "Digital Audio" to identify this machine.  System Profiler has the following information:
    Machine Name:          Power Mac G4
      Machine Model:          PowerMac3,5
      CPU Type:          PowerPC G4  (2.1)
      Number Of CPUs:          1
      CPU Speed:          800 MHz
      L2 Cache (per CPU):          256 KB
      Memory:          768 MB
      Bus Speed:          133 MHz
      Boot ROM Version:          4.3.3f2
      Serial Number:          XBxxxxxMK9
      Sales Order Number:
    Yes, I could connect them by ethernet if all I wanted to do was transfer files, but I would like to network them so I could use wireless internet.  The machines are not always so close together, I did that to simplify the testing.  With the very slow transfer speeds I am reluctant to move ahead with the internet step. 
    <Edited By Host>

  • HT1338 I have a Mac Mini running OSX version 10.8.5 and I want to connect an HP OfficeJet K60 printer using a USB connection.  How do I do this please?  I am not very computer literate so simple instructions would be helpful!

    I have a Mac Mini running OSX version 10.8.5 and I want to connect an HP OfficeJet K60 printer using a USB connection.  How do I do this please?  I am not very computer literate so simple instructions would be helpful!

    Hi Johnfromglenver,
    There are no Mac drivers for the HP Officejet K60 printer. Therefore it is not compatible with the Mac operating systems. Please call our technical support at 800-474-6836. If you live outside the US/Canada Region please click the link below to get the support number for your region. http://www.hp.com/cgi-bin/hpsupport/index.pl. There may be other solutions that could work for you.
    I hope this information helps.
    Advance 23
    I work on behalf of HP

  • Using Firefox on Windows 7, if I leave Firefox running but the computer not connected to the internet (while I leave the computer for a while), Firefox reconnects to the internet. How do I stop this?

    If I leave my computer unattended, with Firefox running but the computer not connected to the internet (using a modem), Firefox (or the pages displayed on it) will reconnect with the internet. I have not allowed auto-reconnection. So how do I stop this?

    install new copy on os
    try again

  • How to using sqlplus to connect and run command ?

    Hello,i have a small problem please help me
    I want to use sqlplus to connect and run command
    for example : sqlplus test/test@DB select sysdate from dual ;
    and then it will show data (sysdate) to screen
    what should i do ?
    Thanks

    kenshin19xx wrote:
    Hello,i have a small problem please help me
    I want to use sqlplus to connect and run command
    for example : sqlplus test/test@DB select sysdate from dual ;
    and then it will show data (sysdate) to screen
    what should i do ?
    Thanks
    bcm@bcm-laptop:~$ echo "select sysdate from dual ;" > now.sql
    bcm@bcm-laptop:~$ sqlplus user1/user1 @now
    SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 14 20:41:33 2011
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SYSDATE
    2011-12-14 20:41:33

Maybe you are looking for

  • Installation CR2008 trial error message in Windows 7.

    Hi, Current window : Windows 7 I have install crystal report 2008 trial version in windows 7 and the error message: 1) When i open my project in vb6  error msg : c:\windows\system32\crystl32.ocx could not be loaded -- continue loading project? 2) the

  • Loading file name sqlldr

    Hi I have a directory which get almost 10-20 files ever day, i have to laod them using sql loader. I have to load a file name i acolumnas well which ever file sqlloader is processing. file1 file2 file3 file4 when sql loader has to laod in the below t

  • Resizing Images Using LR3

    Specify Image Export Sizing. Question. The Adobe LR3 Help section says in th Specify image export sizing page: When exporting using the dimension option that the horizontal and vertical dimensions can be changed IRRESPECTIVE of the original values or

  • HT201210 hi is asking me to activate my phone and itty so many times and still not letting me to do it

    hi is asking me to activate my phone how can i do that

  • ICS on 2GB A1 - internal storage problem.

    Hi Question to Lenovo support. It is possible to flash 2GB A1 version to the newest ICS from OTA .... but .... after that we have only 240 MB internal storage available. Is there any fix for that possible ? And please add same feature as in Cyanogenm