Win a copy of Securing DevOps this week in the Security forum!

Sen George

Ranch Hand
+ Follow
since Sep 21, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sen George

Hello,

Thanks for the tip. When I added the jstl library to the project and rebuilt the project, it all worked fine. Thanks for the help.

Regards,
Sen
6 years ago
JSP
Hello,
I am using NetBeans IDE 7.0.1 and the Tomcat server version is 7.0. I am trying to run a simple jsp which is given below.

<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title> JSP is easy</title>
</head>
<body>
<%-- Calculate the sum of 1+2+3+4 dynamically --%>


<h2>
1 + 2 + 3 + 4 = <c:out value="${1+2+3+4}" />
</body>
</html>

In the IDE, against the taglib line, the error "The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application" is shown. The jar file jstl-api-1.2.jar is present under WEB-INF/lib directory.

And, while trying to run the file, the error "org.apache.taglibs.standard.tag.rt.core does not exist" is shown in the log.

Please advise how this error can be rectified.
6 years ago
JSP
I got it to work finally. As per the Tomcat documentation, the jar file-ojdbc6.jar-needs to be present only in $CATALINA_HOME/common/lib directory. I had the jar file in this directory earlier also, but don't know why it threw up errors. The only concrete thing which comes to my mind is that while trying different options, I had changed the value for the type attribute from "javax.sql.DataSource" to ""javax.jsp.jstl.sql.DataSource" in the context.xml file. Think I didn't change it back after copying the jar file. Anyways, it works now.

I was almost giving up. Thank you all for the tips and help.
8 years ago
Placed the jar file under server/lib instead of common/lib and also added the entry of the jar file in PATH variable-still no luck. The database indeed works with tools like Oracle SQL*Plus and JDeveloper.

Also, I am wondering about the significance of the string value in the entry driverClassName="oracle.jdbc.OracleDriver" in the file context.xml. Shouldn't the driverClassName should be just 'OracleDriver'? Does the path to the class file be identical to the one in the definition above? Please advise.
8 years ago
I have removed the ojdbc6.jar file from the WEB-INF/lib directory and still the same results. I have verified that the jar file has the file OracleDriver.class. Here is the code I am using to test the database connectivity issue.


Please advise.
8 years ago
I am running Tomcat 5.5 and Java JDK 1.6. I am facing a jdbc connectivity issue while trying to connect to a local Oracle database (version 11.1.0) installed on my laptop. The required changes-I trust-have been made in the files context.xml and web.xml. The relevant listings from both files are as follows:

context.xml


<!-- The contents of this file will be loaded for each web application -->
<Context>

<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>

<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->

<!-- Oracle DB Connection Pool -->
<Resource name="jdbc/myOracle" auth="Container"
type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:abelandr"
username="hr" password="hr" maxActive="20" maxIdle="10"
maxWait="-1"/>

</Context>



web.xml


<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/myOracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

</web-app>



I have placed the relevant jar file ojdbc6.jar in the directories CATALINA_HOME/common/lib as well as [web app name]/WEB-INF/lib. In spite of all this, the error message received is as follows (partial listing):


org.apache.jasper.JasperException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc/myOracle"
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc/myOracle"
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.db_005ftest_jsp._jspService(db_005ftest_jsp.java:83)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)



Please advise what is being missed out here.

Thanks.
8 years ago
With reference to the following code,


I know that HttpServletRequest interface extends javax.servlet.ServletRequest interface and the implementing class for ServletRequest interface is the ServletRequestWrapper class. My doubt is that how is a call like 'request.getParameter', for example, resolved at runtime. Is this something done by a container?
9 years ago
The following code


compiles and runs fine.

Program produces an output of 'match' found in positions 0, 1, 2, 3, 4, 5, 6, 7, and 8. But no data groups. How is this explained-matches found but no data groups?

9 years ago
The following code does not seem to create a new text box as intended. Please help.

Trust that is what lines 12 through 14 does. Please clarify.
I have the following code:



The 2 stylesheets referred are:

normalText.css

p.text {font-family:arial; font-color:#FF66FF; font-weight:bold; font-stretch:ultra-expanded; text-align:center}


bigText.css
p.text {font-family:arial; font-color:#FF00CC; font-size:28; font-weight:bold; text-align:center}

On running the program, the page appears fine and there are no errors. But the stylesheet is not getting applied. On switching between the radio buttons, the title shows the correct stylesheet being referenced.

Please help.


Thanks for pointing out the scoping issue. I fixed that and the program compiles fine now. However, I had to change the
to


Does this imply that if I were to add integers to the list variable brands, the code should be changed to:


I was under the impression that without generics, the ArrayList object would take an object of any type.
9 years ago
I doubt the class file is getting created. By the way, I am using Java version 1.6
9 years ago
The following code does not compile


On compiling with -Xlint option, the errors displayed are:

test_list.java:22: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List
brands.add("green");
^
test_list.java:23: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List
brands.add("magenta");
^
test_list.java:26: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List
brands.add("light brown");
^
test_list.java:27: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.List
brands.add("light red");
^
test_list.java:32: cannot find symbol
symbol : variable brands
location: class test_list
return (brands);
^
test_list.java:32: illegal start of type
return (brands);
^

Please help.
9 years ago
In the following code,

the output got is 'In doIt method' followed by ' Thread is running.'

I was expecting the output in reverse- ' Thread is running.' followed by ' In doIt method'. Could someone please clarify this behavior?
9 years ago