Problem with a path in a servlet

hello,
I have a servlet - jsp pair that I am trying to deploy. This is an example I found online and I am trying it out using Tomcat 4.1 however I keep getting errors and hope someone can tell me what I am missing.
I have compiled the servlet successfully. When I try to invoke it, I get the following error:
java.lang.IllegalArgumentException: Path login.jsp does not start with a "/" character
I know that the problem is in the disp = app.getRequestDispatcher("login.jsp");
line but not sure how to correct it. I have included the syntax for both servlet and jsp and also the paths where they are located in my tomcat directory
the servlet is located in the following directory in tomcat:
c:/tomcat4.1/webapps/root/web-inf/classes/jsp/GuestJsp.class
Here is the syntax for the GuestJsp.java servlet is:
package jsp;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
* GuestJsp is a servlet controlling user
* interaction with the guest book.
public class GuestJsp extends HttpServlet {
* doGet handles GET requests
public void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException, IOException
// Save the message in the request for login.jsp
req.setAttribute("message", "Hello, world");
// get the application object
ServletContext app = getServletContext();
// select login.jsp as the template
RequestDispatcher disp;
disp = app.getRequestDispatcher("login.jsp");
// forward the request to the template
disp.forward(req, res);
the jsp is located in c:/tomcat4.1/webapps/root/login.jsp
the syntax for the login.jsp is:
<%@ page language=javascript %>
<head>
<title><%= request.attribute.message %></title>
</head>
<body bgcolor='white'>
<h1><%= request.attribute.message %></h1>
</body>
thanks in advance
java newbie

Doesn't it seem intuitively obvious from the error message that perhaps you should try "/login.jsp" instead of "login.jsp"?

Similar Messages

  • Problem with file path in linux

    hi,
    i have problem with file path accessing in linux. my java class is accessing a abc.cvs file and and getting all data. it is working fine in windows xp. but i run this same file in linux it does not access the abc.cvs file and does not get any data.
    my project structure
    Search
    abc.cvs
    search.SearchMain
    i am sccessing this cvs file in this SearchMain class by this way file name = "abc.cvs"
    It is working fine with window but problem with linux.
    when i place this abc.cvs in a folder as "./data/abc.cvs" also working fine with windows but not in linux.
    I am new for linux.
    Please give me solution.
    Thanks in advance
    Ravi

    forgot to tell,
    then you need to export that path
    export $CLASSPATH
    code}                                                                                                                                                                               

  • Nautilus have problem with opening paths other than /home

    Hi,
    I have strange problem with nautilus. When I want to open some path ie. /media/*some mounted device* or /tmp usign gnome-menu "Places" I see hourglass cursor for a while and then nothing happens. Only home would open with "Places" however typing nautilus path in console opens the specified path instantly. If I open /home and then go to desired place and next try to again open this path with "Places" menu it works.
    How could I fix this issue?
    Last edited by karm (2011-01-27 20:54:26)

    karm wrote:
    Sorry for late reply I was not here for a while.
    here are the permissions:
    /media
    drwxrwx--- 1 root staff 8,0K 02-13 04:35 wd
    Unless your user is part of the "staff" group, you wouldn't be ale to open "wd".
    drwxrwxrwt 14 root root 20K 02-20 03:03 tmp
    Permissions are good here.  You should be able to open everything.  *But* if you want, issue a "chown root:users" on /tmp as root and see if that makes a difference.  (I'm assuming "users" is your default group.  It is for me on Arch.)
    /home
    drwxr-xr-x 49 karm root 20K 02-19 21:07 karm
    You own home so that is as it should be.
    > As I wrote before, only /home is opening corectly. It may be important that /media/wd is a mount point of an external usb hard drive. Does this ring some bells?
    >Regards,
    >karm
    I don't know if you're having a Gnome specific issue or not but I would play around with changing ownership of the problematic folders to your user and see if it makes a difference.

  • Problem with image path names

    We have a website created in CF4.5 and is hosted on our own server, call it www.oldsite.com  A vendor created a new website which is hosted at another location and it uses the same name and the DNS info was updated so this new site has the same name and now runs when our oldsite name is used.
    The vendor created a new name - "legacy.oldsite.com" and pointed to our old IP address at our office and serverfor the origonal site.  We have lots of customer support info on the old site and wanted customers to be able to find these docnuments.  When we type "legacy.oldsite.com" we land on an index.cfm page one folder above the orogional index.cfm rathee rthan the old index.cfm page.  I have added a tag to this page to go to the correct index.cfm page.  But the problem now is that all the images on the site and the documents are missing or will not download.  When I look at the path of these images and documents, some images start with Http://www.oldsite.com/etc"  some are "http://legacy.oldsite.com/path" (In this case some folder name is missing in the path so it does not work).  So it looks like the path is coded somewhere?  I see no other way that the www.oldsite.com path could be read any other way.  So does anyone have may ideas where I mightbe able to fix this issue and get the old site to load images and documents?
    Thanks
    TedT

    I never used the compressed folder option nor I'm sure I really understand what this feature is.I can browse "into" an archive, open it like a folder (is this the "compressed folder" feature?). I extracted the sub folder via drag and drop. The extraction was very slow, but it finished. When I tried to delete the folder, there was an error message stating that the content could not be saved to the trash because of long file names.
    I repeated the test and initially created that awful long path which WinRAR was using (pdt-2.0.0GA_debugger-5.2.15.v20081217-all-in-one-win32) and extracted the archives content into that folder. This time extraction stopped with error message "0x80010135: path too long".
    All if seen so far seems to indicate that there's a max_path problem with Explorer (only x64 version?) and system parts based on it (like wastebasket), not only a problem with WinRAR.
    Windows 7 x64 - Gigabyte EP-45-DS3 (Intel P45 chip set), 4GB RAM, ATI 4670

  • Problems with the path

    Hi
    1. I am using WSAD 5.0
    2. I have created a web project it has the following directory struture
    Java Source
    MyFile.java // This file needs to access the xml in MyData
    Web Content
    // MyData contains few xml and js files
    MyData // POSITION 1
    META-INF
    WEB-INF
    classes
    lib
    MyData // POSITION 2
    MyShow.jsp
    3. In the buildpath the source is set to Java Source
    **Question 1: Which is the correct POSITION of the Folder 'MyData'?
    1. Assuming the folder is placed in POSTION 1
    Java file
    -- What would be correct relative path access the xml file in MyData
    (i tried ../Web Content/MyData/abc.xml,
    ./Web Content/MyData/abc.xml and
    /Web Content/MyData/abc.xml but NOTHING worked)
    <I know the ./ is for current directory and ../ is for parent one and / is for the root >
    Jsp file
    I am ABLE to access the javascript files with path /MyData/abc.js
    2. Assuming the folder is placed in POSTION 2
    Java file
    -- I am ABLE to acces the xml file with the path /MyData/abc.xml
    Jsp file
    -- The file is NOT ABLE to access the path /WEB-INF/MyData/abc.js (WSAD automatically also creates the same path)
    **Question 2: Depending on the position of folder how would i access MyData from JSP or Java file
    -- One more important thing is that in WSAD 5.1 the folder created is 'WebContent' instead of 'Web Content' <without space>, Does it has any thing to do with it?
    Any help would be highly appreciated, any links which would give my insight on this will also be of immense help
    regards
    Tarun Dhillon

    I am not sure i understand your problem, however you need to arrange your directories so that they are in a logical order from the context root for your application
    for Websphere Developer questions, you should probably try an websphere newsgroup as well.

  • EP 7.0 Install Problem with JDK path

    I’m having a problem with installing EP 7.0 on Solaris. We had Solaris 8 and then performed a fresh install of Solaris 10. Solaris 10 had Java 1.5. When performing the EP install at the step to supply the JDK directory message stating 1.5.0 was not supported. I had to install JDK from 1.4. family. I stopped the install and UNIX group installed 1.4.2_13.  I now receive message that directory /usr/bin is not a valid JDK directory:the java executable is missing. The UNIX team told me this is the valid directory path. I am not sure what the exact problem is. I stopped the install and provided the environment variable JAVA_HOME=/usr/bin and the same problem. Has anyone come across this problem maybe my version is not correct. Any ideas on what could be wrong are greatly appreciated.
    Thanks
    Martin

    Hi Martin,
    why are you pointing JAVA_HOME variable to /usr/bin.
    JAVA_HOME must always point to the directory where JAVA installation resides.So for you it might be /j2sdk1.4.2_13 if the JAVA installation directory is j2sdk1.4.2_13.
    If this does not solve ur problem.
    Please let me know the exact step where u r facing with the problem.
    Hope it helps
    Cheers,
    Santhosh

  • Problems with file paths in ApplescriptObjC

    Hi
    I am having a problem with trying to Open/Read/Write/Close text files in ApplescriptObjC. The following piece of script works in Applescript but when I try to incorporate in ASOC via Xcode I get the following error "Can’t make current application into type «class fsrf»"  and I have no idea what that means!
    I've tried using POSIX paths but still doesn't work. As usual, any help gratefully received.
    I am using the Control Record to hold the last reference number used so when I add another row to a spreadsheet it will generate the next unique reference.
    set filePath "Macintosh HD:Users:Ours:Documents:Cats Protection:Control Record.txt"
    set fileReference to open for access (file filePath) with write permission
    set lastNumber to read alias filePath -- read all data
    set nextNumber to (text -1 thru -2) of lastNumber as integer -- extract last number
    set nextNumber to (nextNumber + 1) -- increment number
    set nextNumber to text (2 * -1) thru -1 of ("0" & nextNumber) -- add leading zero
    write nextNumber to fileReference starting at 9 -- update next number
    close access fileReference

    «class fsrf» is a file system reference. Long story, but cocoa changed the preferred way to handle file references (in 10.6, I think) and sometimes applescript trips over the difference.
    try changing the first three lines like so:
    set filePath to "/Users/Ours/Documents/Cats Protection/Control Record.txt"
    set fileReference to open for access filePath with write permission
    set lastNumber to read fileReference -- read all data
    Cocoa is generally happier with posix paths, open for access shouldn't need the file keyword, and reading from the file reference (rather than specifying the file again) is cleaner.

  • Problem with long path names?

    I tried to unpack the PHP eclipse package to a folder named like the ZIP package (pdt-2.0.0GA_debugger-5.2.15.v20081217-all-in-one-win32). WinRAR stopped with an error message (something like "file name to long"). I was unable to delete the folder until I shortened the directory name. Extracting worked only with a short path name.
    Did anybody experience something like this?
    Windows 7 x64 - Gigabyte EP-45-DS3 (Intel P45 chip set), 4GB RAM, ATI 4670

    I never used the compressed folder option nor I'm sure I really understand what this feature is.I can browse "into" an archive, open it like a folder (is this the "compressed folder" feature?). I extracted the sub folder via drag and drop. The extraction was very slow, but it finished. When I tried to delete the folder, there was an error message stating that the content could not be saved to the trash because of long file names.
    I repeated the test and initially created that awful long path which WinRAR was using (pdt-2.0.0GA_debugger-5.2.15.v20081217-all-in-one-win32) and extracted the archives content into that folder. This time extraction stopped with error message "0x80010135: path too long".
    All if seen so far seems to indicate that there's a max_path problem with Explorer (only x64 version?) and system parts based on it (like wastebasket), not only a problem with WinRAR.
    Windows 7 x64 - Gigabyte EP-45-DS3 (Intel P45 chip set), 4GB RAM, ATI 4670

  • SQL*Loader problem with direct path load

    Hi all,
    Its on Oracle 9.2
    I have a sqlldr control file which has couple of columns like,
    my_column_1 ,
    my_column_2 "decode(:my_column_1,'ONE','AAA','TWO','BBB', :my_column_1)"
    The table I am loading to is in user X and I am running the load from
    user Y. Everything works fine with conventional path load (not direct
    path) as grants are made for the table to user Y.
    When I load the data with same control file with direct path, I get an
    error ,
    01031 - insufficient privileges
    Is this anything to do with the syntex I have used in the control file
    or its a privilege issue. If its a privilege issue which privilege is
    that ?
    I did following tests,
    1) Load is run with conventional path load, from user Y and the decode
    statement is in control file - Load works
    2) Load is run with direct path load, from user Y and decode statement
    is in control file - Load fails with above mentioned error
    3) Load is run with direct path load, from user Y and decode IS REMOVED
    from the control file - Load works (!!!)
    What can be the conclusion? Way out ?
    Thanks and Regards

    You need to grant
    grant lock any table to userY;
    For more information see MetaLink Note 1082550.6

  • Problem With Deploying a very simple Servlet

    HELP REQUIRED:
    Hi,
    I'm including code of a very simple Servlet application (I shd not call it an application):
    index.html
    ==========
    <html><body bgcolor="#FFFFFF">
         <head>
         <title> Rajeev Asthana </title>
    <form action = "/HelloWorldApp/HelloWorld" method = "POST" >
    Please press Submit
    <input type = "submit" value = "Press Me!">
    </form>
    </body></html>
    HelloWorld.java
    ===============
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorld extends HttpServlet {
         public void doPost(HttpServletRequest request,
                   HttpServletResponse response)
              throws ServletException, IOException {
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              out.println("<html><body bgcolor=\"#FFFFFF\">");
              out.println("<p>Hello World!</p>");
              out.println("</body></html>");
              out.close();
    web.xml
    ========
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>HelloWorldApp</display-name>
    <servlet>
    <display-name>HelloWorld</display-name>
    <servlet-name>HelloWorld</servlet-name>
    <servlet-class>HelloWorld</servlet-class>
    </servlet>
    </web-app>
    sun-web.xml
    ===========
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.0 Servlet 2.4//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-0.dtd">
    <sun-web-app xmlns="http://java.sun.com/xml/ns/j2ee">
    <context-root>/HelloWorldApp</context-root>
    <session-config>
    <session-manager persistence-type="memory">
    <manager-properties/>
    <store-properties/>
    </session-manager>
    <session-properties/>
    <cookie-properties/>
    </session-config>
    <cache enabled="false" max-entries="4096" timeout-in-seconds="30">
    <default-helper/>
    </cache>
    <class-loader delegate="true"/>
    <jsp-config/>
    </sun-web-app>
    I have deployed it in following directory structure:
    C:\Sun\AppServer\domains\domain1\applications\j2ee-modules\HelloWorldApp\
    |
    |
    |               |               |               |
    |               |               |               |
    META-INF          WEB-INF          HelloWorld.java          index.html
                   |
                   |
              |          |          |          |
              |          |          |          |
         classes          sun-web.xml     web.xml          sun-j2ee-ri-project
         |
         |
         HelloWorld.class
    While generating HelloWorldApp.war (which is the war file for this app), I specifies /HelloWorldApp as context root (sun specific).
    Now, when I deployed it thru Admin Tool and then clicked on "Launch", it displays a page with :
    Please press Submit Press Me!
    But when I click the button "Press Me!", it says:
    "The requested resource (/HelloWorldApp/HelloWorld) is not available."
    What should I do to correct the problem?
    Thanks in advance.
         

    Yes, you need to add a servlet -mapping element and adjust your form to submit to the appropriate URL mapping.
    <servlet-mapping>
    <servlet-name>HelloWorldServlet</servlet-name>
    <url-pattern>/servlet/Hello</url-pattern>
    </servlet-mapping>

  • A problem with Package Paths.... i think

    Hey im struggling with these errors im getting.
    First i should ecplain the layout
    this is the directory im working with
    public_html>WEB_INF>classes>com
    Ok i have 3 java files in here which all compile happily until i try and put them into a package. Once i do this the DbBean,java file complains that it cannot find the other 2 files
    This is the error i get when i try to compile it
    ============================================================
    DbBean.java:108: cannot find symbol
    symbol : class Product
    location: class com.DbBean
    public Product getProductDetails(int productId) {
    ^
    DbBean.java:69: cannot find symbol
    symbol : class Product
    location: class com.DbBean
    Product product = new Product();
    ^
    DbBean.java:69: cannot find symbol
    symbol : class Product
    location: class com.DbBean
    Product product = new Product();
    ^
    DbBean.java:93: cannot find symbol
    symbol : class Product
    location: class com.DbBean
    Product product = new Product();
    ^
    DbBean.java:93: cannot find symbol
    symbol : class Product
    location: class com.DbBean
    Product product = new Product();
    ^
    DbBean.java:109: cannot find symbol
    symbol : class Product
    location: class com.DbBean
    Product product = null;
    ^
    DbBean.java:117: cannot find symbol
    symbol : class Product
    location: class com.DbBean
    product = new Product();
    ^
    DbBean.java:149: cannot find symbol
    symbol : class ShoppingItem
    location: class com.DbBean
    ShoppingItem item = (ShoppingItem) enume.nextElement();
    ^
    DbBean.java:149: cannot find symbol
    symbol : class ShoppingItem
    location: class com.DbBean
    ShoppingItem item = (ShoppingItem) enume.nextElement();
    ^
    Note: DbBean.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    ==========================================================
    The files in the directory are DbBean.java, Product.java and ShoppingItem.java
    Here is the code of each file.
    package com;
    import java.util.Hashtable;
    import java.util.ArrayList;
    import java.util.Enumeration;
    import java.sql.*;
    import com.DbBean.*;
    //import com.DbBean.Product;
    //import com.DbBean.ShoppingItem;
    import java.util.*;
    public class DbBean {
    public String dbUrl = "";
    public String dbUserName = "";
    public String dbPassword = "";
    public void setDbUrl(String url) {
    dbUrl = url;
    public void setDbUserName(String userName) {
    dbUserName = userName;
    public void setDbPassword(String password) {
    dbPassword = password;
    public Hashtable getCategories() {
    Hashtable categories = new Hashtable();
    try {
    Connection connection = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
    Statement s = connection.createStatement();
    String sql = "SELECT CategoryId, Category FROM Categories" +
    ResultSet rs = s.executeQuery(sql);
    while (rs.next()) {
    categories.put(rs.getString(1), rs.getString(2) );
    rs.close();
    s.close();
    connection.close();
    catch (SQLException e) {}
    return categories;
    public ArrayList getSearchResults(String keyword) {
    ArrayList products = new ArrayList();
    try {
    Connection connection = DriverManager.getConnection(dbUrl, dbUserName,
    dbPassword);
    Statement s = connection.createStatement();
    String sql = "SELECT ProductId, Name, Description, Price FROM Products" +
    " WHERE Name LIKE '%" + keyword.trim() + "%'" +
    " OR Description LIKE '%" + keyword.trim() + "%'";
    ResultSet rs = s.executeQuery(sql);
    while (rs.next()) {
    Product product = new Product();
    product.id = rs.getInt(1);
    product.name = rs.getString(2);
    product.description = rs.getString(3);
    product.price = rs.getDouble(4);
    products.add(product);
    rs.close();
    s.close();
    connection.close();
    catch (SQLException e) {}
    return products;
    public ArrayList getProductsInCategory(String categoryId) {
    ArrayList products = new ArrayList();
    try {
    Connection connection = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
    Statement s = connection.createStatement();
    String sql = "SELECT ProductId, Name, Description, Price FROM Products" +
    " WHERE CategoryId=" + categoryId;
    ResultSet rs = s.executeQuery(sql);
    while (rs.next()) {
    Product product = new Product();
    product.id = rs.getInt(1);
    product.name = rs.getString(2);
    product.description = rs.getString(3);
    product.price = rs.getDouble(4);
    products.add(product);
    rs.close();
    s.close();
    connection.close();
    catch (SQLException e) {}
    return products;
    public Product getProductDetails(int productId) {
    Product product = null;
    try {
    Connection connection = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
    Statement s = connection.createStatement();
    String sql = "SELECT ProductId, Name, Description, Price FROM Products" +
    " WHERE ProductId=" + Integer.toString(productId);
    ResultSet rs = s.executeQuery(sql);
    if (rs.next()) {
    product = new Product();
    product.id = rs.getInt(1);
    product.name = rs.getString(2);
    product.description = rs.getString(3);
    product.price = rs.getDouble(4);
    rs.close();
    s.close();
    connection.close();
    catch (SQLException e) {}
    return product;
    public boolean insertOrder(String contactName, String deliveryAddress,
    String ccName, String ccNumber, String ccExpiryDate, Hashtable shoppingCart) {
    boolean returnValue = false;
    long orderId = System.currentTimeMillis();
    Connection connection = null;
    try {
    connection = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
    connection.setAutoCommit(false);
    Statement s = connection.createStatement();
    String sql = "INSERT INTO Orders" +
    " (OrderId, ContactName, DeliveryAddress, CCName, CCNumber, CCExpiryDate)" +
    " VALUES" +
    " (" + orderId + ",'" + contactName + "','" + deliveryAddress + "'," +
    "'" + ccName + "','" + ccNumber + "','" + ccExpiryDate + "')";
    s.executeUpdate(sql);
    // now insert items into OrderDetails table
    Enumeration enume = shoppingCart.elements();
    while (enume.hasMoreElements()) {
    ShoppingItem item = (ShoppingItem) enume.nextElement();
    sql = "INSERT INTO OrderDetails (OrderId, ProductId, Quantity, Price)" +
    " VALUES (" + orderId + "," + item.productId + "," +
    item.quantity + "," + item.price + ")";
    s.executeUpdate(sql);
    s.close();
    connection.commit();
    connection.close();
    returnValue = true;
    catch (SQLException e) {
    try {
    connection.rollback();
    connection.close();
    catch (SQLException se) {}
    return returnValue;
    package com;
    public class Product
    public int id;
    public String name;
    public String description;
    public double price;
    package com;
    public class ShoppingItem
    public int productId;
    public String name;
    public String description;
    public double price;
    public int quantity;
    I'm sure it has something to do with my directory structure, Were using a Tomcat server through Uni so i dont have access to change the context paths or anything like that. Any way to over come this problem would be so much appreciated! if your from Melbourne i'll buy u a beer ;o)
    Thanks heaps.
    Message was edited by:
    SomethingStupid

    if you start javac in your directory
    public_html>WEB_INF>classes>com
    the compiler cannot find the the classes Product and ShoppingItem.
    Start the compiler in public_html>WEB_INF>classes:
    javac com/*.javaThe path
    public_html/WEB_INF/classes
    is in your case the classpath. javac uses the current working directory as default classpath. The classpath contains "root points" of package directory trees.

  • File Attachment in a Email.... problem with file path

    Hi experts
    I am trying to implement something similar to any email program.
    A user can send email to a user along with attachments.
    I am encountering the following problems:
    1) in IE, the file path is set correctly, but in mozilla only the file name is set. (how do i get the file path in mozilla??)
    2) if i add the file as part of the body in the email, the destination user should only see only the file name and not the entire file path of the source computer.
    any help would be appreciated
    thanx
    deepak

    File on web forms is attached to the case. Go to the case in the admin and you can retrieve the file.

  • Problems with several statements in one servlet

    Hi!
    I use the jdbc:odbc bridge driver, and an Access database. I'm making a webshop, and everything is working except for one thing: I can't insert several OrderItems at the same time.
    I have a basket structure, where I have several OrderItem objects. In these objects, I have product_id, price, quantity etc in each object.
    My database have to related tables, Order and OrderItem. I first insert a new order into the Order table. That works. Then I try to read the Order table to find the highest Order ID, which will then be used when I insert data into the OrderItem table.
    The problem is that if I add any more statements to the same servlet, I get a Invalid Cursor type error.
    This is the code that works:
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn = DriverManager.getConnection("jdbc:odbc:Network");
    Statement stmt = conn.createStatement();
    java.util.Date date = new java.util.Date();
    java.sql.Date sqlDate = new java.sql.Date(date.getTime());
    String strDate =String.valueOf(sqlDate);
    stmt.executeUpdate("INSERT INTO Order2(CustID, Ordertime) VALUES("+id+", '"+strDate+"');");
    stmt.close();
    conn.close();
    }catch (Exception e){
         out.println("Error: " + e);
    This is the code that doesn't work:
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn = DriverManager.getConnection("jdbc:odbc:Network");
    Statement stmt = conn.createStatement();
    java.util.Date date = new java.util.Date();
    java.sql.Date sqlDate = new java.sql.Date(date.getTime());
    String strDate =String.valueOf(sqlDate);
    stmt.executeUpdate("INSERT INTO Order2(CustID, Ordertime) VALUES("+id+", '"+strDate+"');");
    Statement stmt2 = conn.createStatement();
    ResultSet rs = stmt2.executeQuery("SELECT Max(OrdID) as max FROM Order2");
    //this will be used to insert the OrderItems
    int MaxOrderID = rs.getInt("max");
    rs.close();
    stmt2.close();
    stmt.close();
    conn.close();
    }catch (Exception e){
    out.println("Error: " + e);
    This is the error I get:
    Error: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
    I've tried using the same statement, using another connection, closing the first statement before I create a new one etc. But nothing works.
    Any suggestions?
    Any help appreciated!
    Vidar

    Error: java.sql.SQLException: [Microsoft][ODBC Driver
    Manager] Invalid cursor state
    I've tried using the same statement, using another
    connection, closing the first statement before I
    create a new one etc. But nothing works.I could imagine that this is the same again like here:
    http://forum.java.sun.com/thread.jsp?forum=48&thread=147704
    Simply try after your INSERT a dummy query like
    "SELECT 1 FROM <yourtable>"
    I'd be interested if it helps.

  • Problem with absolute path and context using Tomcat 4

    I added the following line to my server.xml:
    <Context path="/track" docBase="track" />Now I have used absolute paths(ex: /includes/css/style.css) throughout my code and it worked when I served my application from the ROOT context but when I moved it to the /track - the paths did not include the new root context.
    So instead of looking at http://localhost/track/includes/css/style.css it still looks at http://localhost/includes/css/style.css.
    Is there any kind of setting I am missing in the web.xml or server.xml? I really would like to be able to use absolute paths relative to the context root.
    Please help! Thanks in advance.
    -Chris

    Hi,
    I am not sure what exactly you are asking but here is my shot. If one tomcat is serving more than one application then the only way for tomcat to know which application to refer is by looking at the context path. Since you have the context path of /track then it should appear in all of your urls being directed to the server (for both servlet and jsp). Since you have used absolute path in all the cases either you will have to change the absolute path or you will have to define them relative (which is a better idea) to a base dir. Hope it helps.
    I added the following line to my server.xml:
    <Context path="/track" docBase="track"
    />Now I have used absolute paths(ex:
    /includes/css/style.css) throughout my code and it
    worked when I served my application from the ROOT
    context but when I moved it to the /track - the paths
    did not include the new root context.
    So instead of looking at
    http://localhost/track/includes/css/style.css it still
    looks at http://localhost/includes/css/style.css.
    Is there any kind of setting I am missing in the
    web.xml or server.xml? I really would like to be able
    to use absolute paths relative to the context root.
    Please help! Thanks in advance.
    -Chris

  • Problems with Database connection from a servlet

    Hi everybody:
    I got the following message:
    java.lang.ClassNotFoundException: weblogic/jdbc/oci/Driver
    when I try to connect to a Database.
    public Connection getConnection()
    Connection con = null;
    Driver myDriver = null;
    try
    Properties props = new Properties();
    props.put("user", "fangc");
    props.put("password", "fangc");
    myDriver = (Driver) Class.forName("weblogic.jdbc.oci.Driver").newInstance();
    con = myDriver.connect("jdbc:weblogic:oracle:occd01", props);
    catch(Exception e)
    System.out.println("Connection failed! - " e);
    finally
    return con;
    What am I doing wrong? I try the code without problem for a simple Java Client

    Cristina Fang wrote:
    >
    Hi everybody:
    I got the following message:
    java.lang.ClassNotFoundException: weblogic/jdbc/oci/DriverYou won't get that unless your code has:
    myDriver = (Driver) Class.forName("weblogic/jdbc/oci/Driver").newInstance();
    Make sure your servlet code is just like the right way that you have it
    below:
    myDriver = (Driver) Class.forName("weblogic.jdbc.oci.Driver").newInstance();
    Joe
    >
    when I try to connect to a Database.
    public Connection getConnection()
    Connection con = null;
    Driver myDriver = null;
    try
    Properties props = new Properties();
    props.put("user", "fangc");
    props.put("password", "fangc");
    myDriver = (Driver) Class.forName("weblogic.jdbc.oci.Driver").newInstance();
    con = myDriver.connect("jdbc:weblogic:oracle:occd01", props);
    catch(Exception e)
    System.out.println("Connection failed! - " e);
    finally
    return con;
    What am I doing wrong? I try the code without problem for a simple Java Client

Maybe you are looking for

  • Runtime Error An exception occured while processing the request

    Hi gurus i have a problem with this #1.5 #001CC4944DC600750000097A0000205800046235A0C4AEEE#1233882376782#com.sap.portal.prt.runtime#sap.com/irj#com.sap.portal.prt.runtime#jsbautista#86842##n/a##586788e0f3ea11ddbc08001cc4944dc6#SAPEngine_Application_T

  • How to change standard text in portal

    How to change standard text in portal Pls reply

  • Query on system object

    hi everyone ,                      i have a query regarding this system object. I have created a system object and assigned it to a user to log on to sap R/3 .its working fine.now my question is i have another user on the R/3 side .now i want to log

  • How to disable output for Delivery and shipment

    Hi experts I would like to disable the output for the delivery and shipment. Please let me know any code logic or function module for this. Thanks and regards, Jayakumar Mani.

  • Demo application removal script

    Where can I find a demo application (the one that comes with Oracle XE, APEX 3.0) removal script? I've tried to remove it via the application builder but something went wrong and the application is gone but the underlying tables are still there. I ca