JDBC - Servlet

  • Thread starter Scott D. Barrish
  • Start date
S

Scott D. Barrish

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
 
R

Ryan Stewart

Scott D. Barrish said:
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.
 
S

Scott D. Barrish

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
 
R

Ryan Stewart

*fixed top post*
in
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.
 
S

Scott D. Barrish

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
 
R

Ryan Stewart

Scott D. Barrish said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top