sven studde

Ranch Hand
+ Follow
since Sep 26, 2006
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
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by sven studde

It's in my previous post:

$ java -version
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-113)
Java HotSpot(TM) Client VM (build 1.5.0_06-68, mixed mode, sharing)

apache-tomcat-6.0.13


[ May 29, 2008: Message edited by: sven studde ]
9 years ago
I got the servlet below to work when the servlet wrote out some html using out.println(). The html displayed correctly in my browser. Then I commented out the out.println() lines, and I tried to attach the info to the request object and then forward the request object to a jsp. However, now I get no output in my browser--just a blank page.



webapps/Beer-v1/result.jsp:
I tried various casts on the value returned by request.getAttribute(), but nothing worked.



BeerExpert.java:


Hmmm...after some more testing, I think the problem is because I'm using List<String> instead of List. When I use List, my browser displays the output correctly, but I get some "Notes" when I compile the code:

Note: src/com/example/model/BeerExpert.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.


Are servlets unable to handle generics?

$ java -version
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-113)
Java HotSpot(TM) Client VM (build 1.5.0_06-68, mixed mode, sharing)

apache-tomcat-6.0.13



Now both versions of my servlet are working. This is the cast that works:


[ May 29, 2008: Message edited by: sven studde ]

[ May 29, 2008: Message edited by: sven studde ]
[ May 29, 2008: Message edited by: sven studde ]
9 years ago
Hi,

I'm trying to install tomcat and I found some installation instructions for tomcat 5.5. I'm going to be using tomcat for local development of servlets and jsp. What version of tomcat should I install? I'm leaning towards 5.5, so that the install won't cause any unforeseen problems plus I'm using the book "Head First Servelts & JSP", which uses the same servlet/jsp spec as 5.5. But the current version of tomcat is 6.x. Should I go with the current version?
10 years ago
Hi,

Can anyone direct me to installation instructions for tomcat on a mac? I want to use tomcat for local development of servlets + jsp. I installed Apache 2.2.4 last week.

Thanks.
10 years ago
An InvalidClassException will be thrown when you change something in your Box class after writing to the file. I have no problems with the files you posted: I can compile and run them and get the expected output.

By the way, for testing purposes you can organize your classes like this:


[ November 11, 2006: Message edited by: sven studde ]
[ November 11, 2006: Message edited by: sven studde ]
11 years ago
Object is a base type for all objects in java. long is not a base type for int. The types long and int are primitive types, and therefore they have no relation to objects and the way objects work (although mysteriously an array can be converted to an Object type).

However, given that you can do this:

int i = 10;
long lng = i;

it wouldn't take a stretch of the imagination to believe you could do this:

int[] nums = {10, 20, 30};
long[] lnums = nums;
[ November 10, 2006: Message edited by: sven studde ]
11 years ago

Does getID() really exist(check spelling) in that class and what is its visibility modifiers?


Check the ArrayList class in the java docs and see for yourself.


Don't declare variables inside loops. Otherwise, they get redeclared everytime through the loop. Instead, declare them outside the loop, and then make assignments to them inside the loop.
[ November 10, 2006: Message edited by: sven studde ]
11 years ago

I preferred to declare i, j and k outside the loops, so that variables don't have to be re-created during each iteration.


Suppose you have a loop like this:

for(int i = 0; i < 10; ++i)

If i was recreated during each interation, how would the ending condition ever be reached?

This helps me check my concepts in various fields.


Do some more reading about for-loops.
[ November 10, 2006: Message edited by: sven studde ]
11 years ago
11 years ago
What does your question have to do with making a context listener? Rather your question has to do with: "How can I compile my .java files?

all of which import package com.example


Why?

When you are having compiling problems (doesn't everybody who programs Java?), you need to post:

1) The directory strucuture
2) The package statements in each file
3) The command you entererd
4) The prompt at which you entered the command

You gave us 1). Post 2), 3), and 4)
11 years ago

when I run follow code have a NullPointerException


Edit your post and add a comment to the line of code on which Java told you the exception occurred. Something like:

//**THE ERROR IS HERE***
[ November 06, 2006: Message edited by: sven studde ]
11 years ago
How about making the font bigger so that it is actually readable?
11 years ago
11 years ago
Photo from browser? You mean like the little picture of a house that is the Home icon?
11 years ago
[REMOVED]. Go here for a free ebook:

www.amazon.com

[ November 06, 2006: Message edited by: sven studde ]
[ November 06, 2006: Message edited by: Ben Souther ]
11 years ago