JDBC - Servlet

Discussion in 'Java' started by Scott D. Barrish, Apr 4, 2004.

  1. Fellow Developers,

    I have this test page to demonstrate JDBC connectivity with Oracle 9i in a
    simple JSP page. When I have the page run in the docROOT of the web
    application, it works just fine by producing the correct output. However,
    when I place it in one directory in from the docROOT in a folder named JSP
    ('cause I want to keepall my jsp pages in a single location) the page breaks
    giving my a FileNotFoundIO exception by the Jasper compiler. I've tried
    changing the URL-Mapping of the servlet in the web.xml file as well as the
    URL in the jsp page when I call the servlet with the exact same results. I
    may just be typing in the worn URL and have not figured out the correct way.

    Directory/File Map is below:

    <BLG>
    -----<Home>
    ----------<WEB-INF>
    ---------------web.xml
    ---------------<Classes>
    --------------------JDBC_Test.class
    ---------------<Lib>
    --------------------ojdbc14.jar
    ----------<JSP>
    ---------------JDBC_Test.jsp
    ----------index.jsp

    Any help is much appreciated.

    Sincerely,
    Scott D. Barrish
    Scott D. Barrish, Apr 4, 2004
    #1
    1. Advertising

  2. Scott D. Barrish

    Ryan Stewart Guest

    "Scott D. Barrish" <> wrote in message
    news:8nYbc.402200$...
    > Fellow Developers,
    >
    > I have this test page to demonstrate JDBC connectivity with Oracle 9i in a
    > simple JSP page. When I have the page run in the docROOT of the web
    > application, it works just fine by producing the correct output. However,
    > when I place it in one directory in from the docROOT in a folder named JSP
    > ('cause I want to keepall my jsp pages in a single location) the page

    breaks
    > giving my a FileNotFoundIO exception by the Jasper compiler. I've tried
    > changing the URL-Mapping of the servlet in the web.xml file as well as the
    > URL in the jsp page when I call the servlet with the exact same results.

    I
    > may just be typing in the worn URL and have not figured out the correct

    way.
    >
    > Directory/File Map is below:
    >
    > <BLG>
    > -----<Home>
    > ----------<WEB-INF>
    > ---------------web.xml
    > ---------------<Classes>
    > --------------------JDBC_Test.class
    > ---------------<Lib>
    > --------------------ojdbc14.jar
    > ----------<JSP>
    > ---------------JDBC_Test.jsp
    > ----------index.jsp
    >
    > Any help is much appreciated.
    >
    > Sincerely,
    > Scott D. Barrish
    >

    Why do you think it's a problem accessing the servlet? I'd suspect an
    include referencing a page that doesn't exist. Check that. If that's not it,
    restart your web server and try it again. If it still breaks, post a
    stacktrace and the code that goes along with it. Without more detail, I
    can't say much more.
    Ryan Stewart, Apr 4, 2004
    #2
    1. Advertising

  3. Ryan,

    Thank you for your support. I am unable to post that information at this
    time for it is at work that I need to do that. There are no include files
    associated with the JDBC_Test.jsp page. It has one line of code using the
    jsp:forward tag with page=/JDBC_Test which is the same Servlet-URL mapping
    parameter I have in my web.xml config file.

    Sincerely,
    Scott D. Barrish

    "Ryan Stewart" <> wrote in message
    news:...
    > "Scott D. Barrish" <> wrote in message
    > news:8nYbc.402200$...
    > > Fellow Developers,
    > >
    > > I have this test page to demonstrate JDBC connectivity with Oracle 9i in

    a
    > > simple JSP page. When I have the page run in the docROOT of the web
    > > application, it works just fine by producing the correct output.

    However,
    > > when I place it in one directory in from the docROOT in a folder named

    JSP
    > > ('cause I want to keepall my jsp pages in a single location) the page

    > breaks
    > > giving my a FileNotFoundIO exception by the Jasper compiler. I've tried
    > > changing the URL-Mapping of the servlet in the web.xml file as well as

    the
    > > URL in the jsp page when I call the servlet with the exact same results.

    > I
    > > may just be typing in the worn URL and have not figured out the correct

    > way.
    > >
    > > Directory/File Map is below:
    > >
    > > <BLG>
    > > -----<Home>
    > > ----------<WEB-INF>
    > > ---------------web.xml
    > > ---------------<Classes>
    > > --------------------JDBC_Test.class
    > > ---------------<Lib>
    > > --------------------ojdbc14.jar
    > > ----------<JSP>
    > > ---------------JDBC_Test.jsp
    > > ----------index.jsp
    > >
    > > Any help is much appreciated.
    > >
    > > Sincerely,
    > > Scott D. Barrish
    > >

    > Why do you think it's a problem accessing the servlet? I'd suspect an
    > include referencing a page that doesn't exist. Check that. If that's not

    it,
    > restart your web server and try it again. If it still breaks, post a
    > stacktrace and the code that goes along with it. Without more detail, I
    > can't say much more.
    >
    >
    >
    Scott D. Barrish, Apr 4, 2004
    #3
  4. Scott D. Barrish

    Ryan Stewart Guest

    "Scott D. Barrish" <> wrote in message
    news:Bp_bc.416533$...
    *fixed top post*
    > "Ryan Stewart" <> wrote in message
    > news:...
    > > "Scott D. Barrish" <> wrote in message
    > > news:8nYbc.402200$...
    > > > Fellow Developers,
    > > >
    > > > I have this test page to demonstrate JDBC connectivity with Oracle 9i

    in
    > a
    > > > simple JSP page. When I have the page run in the docROOT of the web
    > > > application, it works just fine by producing the correct output.

    > However,
    > > > when I place it in one directory in from the docROOT in a folder named

    > JSP
    > > > ('cause I want to keepall my jsp pages in a single location) the page

    > > breaks
    > > > giving my a FileNotFoundIO exception by the Jasper compiler. I've

    tried
    > > > changing the URL-Mapping of the servlet in the web.xml file as well as

    > the
    > > > URL in the jsp page when I call the servlet with the exact same

    results.
    > > I
    > > > may just be typing in the worn URL and have not figured out the

    correct
    > > way.
    > > >
    > > > Directory/File Map is below:
    > > >
    > > > <BLG>
    > > > -----<Home>
    > > > ----------<WEB-INF>
    > > > ---------------web.xml
    > > > ---------------<Classes>
    > > > --------------------JDBC_Test.class
    > > > ---------------<Lib>
    > > > --------------------ojdbc14.jar
    > > > ----------<JSP>
    > > > ---------------JDBC_Test.jsp
    > > > ----------index.jsp
    > > >
    > > > Any help is much appreciated.
    > > >
    > > > Sincerely,
    > > > Scott D. Barrish
    > > >

    > > Why do you think it's a problem accessing the servlet? I'd suspect an
    > > include referencing a page that doesn't exist. Check that. If that's not

    > it,
    > > restart your web server and try it again. If it still breaks, post a
    > > stacktrace and the code that goes along with it. Without more detail, I
    > > can't say much more.
    > >

    > Ryan,
    >
    > Thank you for your support. I am unable to post that information at this
    > time for it is at work that I need to do that. There are no include files
    > associated with the JDBC_Test.jsp page. It has one line of code using the
    > jsp:forward tag with page=/JDBC_Test which is the same Servlet-URL mapping
    > parameter I have in my web.xml config file.
    >
    > Sincerely,
    > Scott D. Barrish
    >

    The forward could be your problem. Is this application accessed via the root
    of your application server or via a context? If you access your page like
    this:
    http://localhost:8888/myApp/JSP/JDBC_Test.jsp

    and then you put
    <jsp:forward page="/JDBC_Test"/>

    somewhere in your page, it will attempt to access
    http://localhost:8888/JDBC_Test

    which can't work because the servlet can't be mapped outside its context.
    Ryan Stewart, Apr 5, 2004
    #4
  5. Ryan,

    I do have the context docROOT set to C:\blg\Home\ whenI type
    http://localhost:8080/index.jsp in the address bar.

    1) I thought that all classes needed for a web application are located in
    WEB-INF\Classes folder and any 3rd party jar files, like my Oracle JDBC
    driver package, is located in the WEB-INF\Lib folder.

    2) Why does this tet page work just fine in the root folder of the web
    application but not when placed one folder down in the hierarchy?

    3) I should be able to place a logical set of folders to better organize my
    jsp files and be able to access my servlets declared in the web.xml file.
    Isn't this why I set a URL-Mapping element in the Servlet tag?

    What would be your suggestion to make this work?

    Sincerely,
    Scott D. Barrish
    Scott D. Barrish, Apr 5, 2004
    #5
  6. Scott D. Barrish

    Ryan Stewart Guest

    "Scott D. Barrish" <> wrote in message
    news:zO1cc.384617$...
    > Ryan,
    >
    > I do have the context docROOT set to C:\blg\Home\ whenI type
    > http://localhost:8080/index.jsp in the address bar.
    >

    You mean http://localhost:8080/JSP/JDBC_Test.jsp should load your page,
    right?

    > 1) I thought that all classes needed for a web application are located in
    > WEB-INF\Classes folder and any 3rd party jar files, like my Oracle JDBC
    > driver package, is located in the WEB-INF\Lib folder.
    >

    Yes, but not just 3rd party. Any JARs go in WEB-INF\lib.

    > 2) Why does this tet page work just fine in the root folder of the web
    > application but not when placed one folder down in the hierarchy?
    >

    No changes at all to the file's contents? All capitalization correct and
    such?

    > 3) I should be able to place a logical set of folders to better organize

    my
    > jsp files and be able to access my servlets declared in the web.xml file.
    > Isn't this why I set a URL-Mapping element in the Servlet tag?
    >

    Yes, this can be helpful, though I typically find the URL mapping to be most
    useful in masking long package names. Not to mention, that I've never been
    able to get a servlet to work without an entry in web.xml, despite more than
    one reference that seemed to indicate it should work. I think that was just
    an old specification though.

    > What would be your suggestion to make this work?
    >
    > Sincerely,
    > Scott D. Barrish
    >

    Mainly, I'd suggest trying to find what line the error occurs on and letting
    us see some code. I'm about out of ideas unless you have something more.
    Ryan Stewart, Apr 5, 2004
    #6
  7. After registering all my servlets and using the new url-mapping below, I m
    now able to use my servelts no matter where in the folder hierarchy I'm at.

    I changed the <url-mapping> element value to /JSP/*

    This is the resource that helped me:
    http://developer.java.sun.com/devel...servlets_javaserver/servlets_javaserver05.pdf

    Sincerely,
    Scott D. Barrish

    "Ryan Stewart" <> wrote in message
    news:...
    > "Scott D. Barrish" <> wrote in message
    > news:zO1cc.384617$...
    > > Ryan,
    > >
    > > I do have the context docROOT set to C:\blg\Home\ whenI type
    > > http://localhost:8080/index.jsp in the address bar.
    > >

    > You mean http://localhost:8080/JSP/JDBC_Test.jsp should load your page,
    > right?
    >
    > > 1) I thought that all classes needed for a web application are located

    in
    > > WEB-INF\Classes folder and any 3rd party jar files, like my Oracle JDBC
    > > driver package, is located in the WEB-INF\Lib folder.
    > >

    > Yes, but not just 3rd party. Any JARs go in WEB-INF\lib.
    >
    > > 2) Why does this tet page work just fine in the root folder of the web
    > > application but not when placed one folder down in the hierarchy?
    > >

    > No changes at all to the file's contents? All capitalization correct and
    > such?
    >
    > > 3) I should be able to place a logical set of folders to better organize

    > my
    > > jsp files and be able to access my servlets declared in the web.xml

    file.
    > > Isn't this why I set a URL-Mapping element in the Servlet tag?
    > >

    > Yes, this can be helpful, though I typically find the URL mapping to be

    most
    > useful in masking long package names. Not to mention, that I've never been
    > able to get a servlet to work without an entry in web.xml, despite more

    than
    > one reference that seemed to indicate it should work. I think that was

    just
    > an old specification though.
    >
    > > What would be your suggestion to make this work?
    > >
    > > Sincerely,
    > > Scott D. Barrish
    > >

    > Mainly, I'd suggest trying to find what line the error occurs on and

    letting
    > us see some code. I'm about out of ideas unless you have something more.
    >
    >
    >
    Scott D. Barrish, Apr 6, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. circuit_breaker
    Replies:
    2
    Views:
    1,978
    Jack Jia
    Apr 4, 2004
  2. Keith Wansbrough

    Re: jdbc help:sun.jdbc.odbc.JdbcOdbcDriver

    Keith Wansbrough, Aug 16, 2004, in forum: Java
    Replies:
    0
    Views:
    733
    Keith Wansbrough
    Aug 16, 2004
  3. Betty
    Replies:
    1
    Views:
    9,842
    Juha Laiho
    May 21, 2005
  4. Jesus M. Salvo Jr.
    Replies:
    2
    Views:
    3,999
    robert
    Feb 11, 2006
  5. Bruce
    Replies:
    4
    Views:
    735
    Bjorn Abelli
    Mar 25, 2006
Loading...

Share This Page