Ken Teoh

Greenhorn
+ Follow
since Jul 20, 2006
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 Ken Teoh

On page 695 of HFSJ Question 4 where it specifies /HopList.do
I was wondering why Filter 2 was not selected. since it is part of Filter 2
servlet name /Recipes/HopList.do
Hey Dilshan,

Thanks alot its working right now. Do you know why its required? I tried it without the line in the example in chapter 3 and it works
Hi Senthil

Was your DD like this?
<web-app xmnls="http://java.sun.com/xml/ns/j2ee" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

<servlet>
<servlet-name>Counter</servlet-name>
<jsp-file>/BasicCounter.jsp</jsp-file>
</servlet>

<servlet-mapping>
<servlet-name>Counter</servlet-name>
<url-pattern>/BasicCounter.jsp</url-pattern>
</servlet-mapping>

</web-app>

I did what you suggested but I get a

org.apache.jasper.JasperException: Unable to compile class for JSP

Thanks
Hi Guys,

I have some trouble deploying the Counter example in chapter 7.
I'm not too sure how the web.xml file is like.
I'm getting an error

The requested resource (/testJSP1/BasicCounter.jsp) is not available.


Here are the details of my web.xml file

<web-app xmnls="http://java.sun.com/xml/ns/j2ee" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<servlet>
<servlet-name>BasicCounter</servlet-name>
<jsp-file>/BasicCounter.jsp</jsp-file>
<servlet-class>Counter</servlet-class>
</servlet>
</web-app>



Thanks for helping
Hi

I clicked on all 3 links but they were invalid.
Can you upload them on another site? If not can you send the file to me at
teooooh@yahoo.com
Hey Caroline,

Thanks alot. I managed to make it work.
Can you explain why using ";" works?

Thanks
I got the same problem initially
check the path of your servlet-api.jar
if you're desperate place the jar file in the same directory as your java source file and it should compile
Hi guys,

I'm having trouble compiling Servlet version 2 of HFSJ on page 85. Apparently,it's having trouble importing the com.example.model.* package.Therefore, the BeerExpert class can't be found. I followed exactly what the book said to do. Can anyone help?

Errors are below

package com.example.model does not exist
import com.example.model.*;
^
src/com/example/web/BeerSelect.java:22: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
src/com/example/web/BeerSelect.java:22: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
3 errors
Tried it without the quotes and it works. However, can some one explain what is the command ":classes:." after the servlet-api.jar is used for? I took it out and it works
Have the same problem

Do we need the :classes:. after the servlet jar?
It doesn't seem to compile after if I use it.
Hi thanks I realize my mistake and change the classpath to

javac -classpath C:/Documents and Settings/Keng/tomcat/common/lib/servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java

however, its giving me an invalid flag error
17 years ago
Hi,

I'm getting these errors when compiling a servlet

src/com/example/web/BeerSelect.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
src/com/example/web/BeerSelect.java:4: package javax.servlet.http does not exist

import javax.servlet.http.*;
^
src/com/example/web/BeerSelect.java:7: cannot find symbol
symbol: class HttpServlet
public class BeerSelect extends HttpServlet {
^
src/com/example/web/BeerSelect.java:9: cannot find symbol
symbol : class HttpServletRequest
location: class com.example.web.BeerSelect
public void doPost(HttpServletRequest request,
^
src/com/example/web/BeerSelect.java:10: cannot find symbol
symbol : class HttpServletResponse
location: class com.example.web.BeerSelect

HttpServletResponse response)

^
src/com/example/web/BeerSelect.java:11: cannot find symbol
symbol : class ServletException
location: class com.example.web.BeerSelect

throws IOException, ServletException {

^
I understand you need to add a jar file but where should I add it and where is it located?

My command was

javac -classpath /common/lib/servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java
17 years ago
Just Passed SCJP. The test was pretty tricky and I thought I bombed the exam.
I was thinking of going with either the scdjws or scwcd. Can any one tell me what are the differences between these two exams in detail? They seem similar to me?
17 years ago
Hi guys, I have a quiz question I hope you guys can understand



public class OrderedThread {
public static void main(String[] args) {
MBThread first,second,third;
OrderedThread orderedThread = new OrderedThread();
first = new MBThread("One",orderedThread);
second = new MBThread("Two",orderedThread);
third = new MBThread("Three",orderedThread);
second.start();
first.start();
third.start();
}

public void display(String msg) {
synchronized (msg) {
for(int i = 1;i<=20;i++) {
System.out.println("Name = " + msg);
}
}
}
}

class MBThread extends Thread {
String name;
OrderedThread orderT;

MBThread(String name, OrderedThread orderT) {
this.name = name;
this.orderT = orderT;
}

public void run () {
orderT.display(name);
}
}


The solution state that two,one and three will be printed in an indefinite order. Do you understand why is this the case? Also, I ran the code in eclipse and it was printing two,one three 20 times each in order. Lastly is there a way to print it in order? Thanks