Help coderanch get a
new server
by contributing to the fundraiser

Asad Salim

Greenhorn
+ Follow
since May 31, 2011
Merit badge: grant badges
For More
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 Asad Salim

I m not able to understand from where should I correct JRE_HOME variable and remove "; from the variable

mango-seeker@ubuntu:/usr/local/tomcat6/webapps/jspbook$ /usr/local/tomcat6/bin/catalina.sh run
Using CATALINA_BASE: /usr/local/tomcat6
Using CATALINA_HOME: /usr/local/tomcat6
Using CATALINA_TMPDIR: /usr/local/tomcat6/temp
Using JRE_HOME: /usr/lib/jvm/java-6-sun";
Using CLASSPATH: /usr/local/tomcat6/bin/bootstrap.jar
exec: 506: /usr/lib/jvm/java-6-sun";/bin/java: not found

The problem exist only with run paramter.

Due to this , I feel I m not able to excute the below ant script


Output is

mango-seeker@ubuntu:/usr/local/tomcat6/webapps/jspbook$ ant
Buildfile: /usr/local/tomcat6/webapps/jspbook/build.xml

build:
[echo] Starting Build (JSP Book)

tomcatOff:
[echo] Turning Off Tomcat
[exec] /usr/local/tomcat6/webapps/jspbook/../../bin/catalina.sh: 506: /usr/lib/jvm/java-6-sun";/bin/java: not found

compile:
[echo] Compiling Book's Examples

tomcatOn:
[echo] Starting Tomcat(JSP Book)
[echo] Build Finished (JSP Book)

BUILD SUCCESSFUL
Total time: 0 seconds

Although the build is successful , i m confused about the above bold statement.

Any help would be appreciated.

Thanks.
12 years ago

C:\MyProject\Beer-V2>javac -classpath "c:\Tomcat 6.0\lib\servlet-api.jar";"c:\MyProject\Beer-V2\src" -d classes src\com\example\web\BeerSelect.java

Solved the issue.
13 years ago
Thanks Bosun Bello , I could figure the problem and could resolve it.
13 years ago
Classpath issue , I m sorry , but i m not able to understand the issue . Since , I m running it from my Development environment folder itself i.e. Beer-v2

Below is my Development Directory structure

c:\>MyProject\Beer-V2> (I m executing the above command from here)

Under Beer-V2 , I have the below folders
src
(BeerExpert.java is located at src\com\example\model)
(BeerSelect.java is located at src\com\example\web)

classes
(BeerExpert.java is located at classes\com\example\model)
BeerSelect.java is not created , as the compilation fails at the below instance

C:\MyProject\Beer-V2>javac -classpath "c:\Tomcat 6.0\lib\servlet-api.jar" -d cla
sses src\com\example\web\BeerSelect.java
src\com\example\web\BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
src\com\example\web\BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
src\com\example\web\BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
3 errors
13 years ago
Hello Guys,

I don't where I'm going wrong in this problem. Below are details:

Below is my BeerExpert.java file which is stored at src/com/example/model



When I compile this file , it gets compile successfully
C:\Beer-V2>javac -d src\com\example\model BeerExpert.java

and create the .class file correctly in the directory classes/com/example/model

But ,when I try to compile BeerSelect.java (Which is at src\com\example\web), which is as below


It tells me that it can't find the package com.example.model as below

C:\MyProject\Beer-V2>javac -classpath "c:\Tomcat 6.0\lib\servlet-api.jar" -d classes src\com\example\web\BeerSelect.java
src\com\example\web\BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
src\com\example\web\BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
src\com\example\web\BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be=new BeerExpert();
^
3 errors

C:\MyProject\Beer-V2>

Thanks in advance
13 years ago
Thanks Joy , that did solve my problem
Hey guys,

I m confused where actually I m going wrong with the classpath settings in order to user JDBC-OracleDriver Connection

Below is my JAVA Code


CLASSPATH setting is :
C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar

Path Setting is
C:\oraclexe\app\oracle\product\10.2.0\server\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\Program Files\Java\jdk1.6.0\bin;

JDK version is 1.6
Oracle version is Oracle 10g

My Code works perfect when i try to on command prompt using -cp , but it doesn't work on Eclipse , it cannot detect the classpath file (i guess so, although being specified)

It throws the below exception
Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at SampleDatabaseConn.main(SampleDatabaseConn.java:9)


Could you guys provide some inputs.

Thanks,
Asad.
yes , it did that was the only issue
13 years ago
JSP
Thanks bear , yes i would remember use CodeTags henceforth.
13 years ago
JSP
I m trying to work on a simple JSP application

Thats my index.jsp
<html>
<head>
<title>Select Your Portal</title>
</head>
<body>
<h1>Select your preferred portal:</h1>
<form name="form1" action="showportal.jsp" method="get">
<select name="portchoice">
<option>news</option>
<option>weather</option>
<option>entertainment</option>
</select>
<input type="submit" value="Click on ME">
</form>
</body>
</html>




Below is showportal.jsp
<%@ taglib prefix="c" uri='http://java.sun.com/jsp/jstl/core" %>
<html>
<c:choose>
<c:when test="${param.portchoice=='news'}">
<jsp:include page="news.jsp"/>
</c:when>
<c:when test="${param.portchoice=='weather'}">
<jsp:include page="weather.jsp"/>
</c:when>
<c:when test="${param.portchoice=='entertainment'}">
<jsp:include page="entertainment.jsp"/>
</c:when>
<c:otherwise>
<jsp:include page="problem.jsp"/>
</c:otherwise>
</c:choose>
</html>


and below is news.jsp
<html>
<head>
<title>News Portal</title>
</head>
<body>
<jsp:useBean id="newsfeed" class="com.wrox.begjsp.ch2.NewsFeed" scope="request">
<jsp:setProperty name="newsfeed" property="topic" value="news"/>
<jsp:getProperty name="newsfeed" property="value" />
</jsp:useBean>
<jsp:include page="dummytext.html"/> <!-- dummytext.html is a dummy.html file-->
</body>
</html>

The application is giving the error below when I select New from the index.jsp and click on "Click on Me"

org.apache.jasper.JasperException: /ex2/showportal.jsp(5,41) equal symbol expected
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
org.apache.jasper.compiler.Parser.parseAttribute(Parser.java:198)
org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:148)
org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:408)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:499)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1558)
org.apache.jasper.compiler.Parser.parse(Parser.java:130)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:245)
org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:161)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:326)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:307)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:309)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

Below is my NewsFeed.java file :

package com.wrox.begjsp.ch2;

import java.beans.*;
import java.util.*;


public class NewsFeed extends Object implements java.io.Serializable {

private String topic;

private String value;

private ArrayList values;

public NewsFeed() {

}


public void setTopic(String topic) {
value = "";
values = null;
if (topic.equals("news")) {
value = "JSP Programmer Won 10 Million in Lottery";
}
if (topic.equals("entertainment")) {
value = "Reality TV Show Ratings Falling";
}
if (topic.equals("weather")){
values = new ArrayList();
HashMap tmap = new HashMap();
tmap.put("city", "Mumbai");
tmap.put("temp", "30 C");
values.add(tmap);
tmap = new HashMap();
tmap.put("city", "Tokyo");
tmap.put("temp", "18 C");
values.add(tmap);
tmap = new HashMap();
tmap.put("city", "Hong Kong");
tmap.put("temp", "28 C");
values.add(tmap);

}

}

public String getValue() {
return this.value;
}

public ArrayList getValues() {
return this.values;
}

}


Thanks in advance. I m confused with what would be the exact problem with this one.

Thanks,
Asad


13 years ago
JSP
Hello,

I have a java file.

Beverage.java stored at e:\

package cert;

class Beverage
{
}

Now , when i compile it
e:\>javac Beverage.java

It compile successfully.

I'm confused why it is not creating a folder named cert and storing Beverage.class file out there.
Instead it is creating Beverage.class at the e:\ itself.

Thanks in advance.
13 years ago