Daniel Loranz

Ranch Hand
+ Follow
since Jun 17, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Daniel Loranz

OK - still stuck getting MVC flavor of BeeServlet to work. Just taking things one at a time ...


The following does NOT compile.
javac BeeServlet.java -classpath /usr/local/tomcat/lib/jr.jar

The following appears to compile just fine - but I don't understand why I don't need to include the jr.jar.
javac BeeServlet.java -classpath /usr/local/tomcat/lib/servlet-api.jar

The following also appears to compile fine.
javac BeeServlet.java -classpath /usr/local/tomcat/lib/jr.jar:/usr/local/tomcat/lib/servlet-api.jar

In no case am I successful in the next step - pointing my browser to BeeServlet and seeing the result. Is something weird happening in the compilation step? Again, I was surprised the compiler seemed OK if I left off the jr.jar classpath.

Thanks.
- Dan
16 years ago
Dang! I totally missed the lowercase 'b' on that. Thanks.

I haven't had a chance to try it out with the correct name yet - been in class and meetings all day. I'll try it out tomorrow.

Thanks again!
16 years ago

Originally posted by Daniel Loranz:

- I copied Bee.jsp to /usr/local/tomcat/webapps/ROOT/



Bee.jsp is the JSP - correct?
16 years ago
I'm stuck getting the MVC BeeServlet example to work. Here's what I have so far.

- I copied jr.jar to /usr/local/tomcat/lib/

- I copied Bee.jsp to /usr/local/tomcat/webapps/ROOT/

- I compile BeeServlet using -classpath /usr/local/tomcat/lib/servlet-api.jar
This gives me BeeServlet.class, BeeServlet$1.class, and BeeServlet$Default.class.
(Does jr.jar also need to be in the classpath?)

- I move the three class files to /usr/local/tomcat/webapps/ROOT/WEB-INF/classes

- I point my browser to http://localhost:8080/servlet/BeeServlet and get HTTP Status 500, The Server encountered an internal error etc.

- I also tried putting the three class files in /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/com/javaranch/drive/ and then point my browser to http://localhost:8080/servlet/com/javaranch/drive/BeeServlet and get HTTP Status 404 - requested resource is not available.

Any help would be most appreciated!

Thanks.
- Dan
16 years ago
I'm asking about the BeeServlet under the MVC section - just before the Servlets-3 assignment.

Your comment about inner classes helps. Thanks. (I haven't seen these yet.)

Thanks.
- Dan
16 years ago
That's new, isn't it? Compiling a single .java file and getting 3 .class files. I think I missed something along the way. Can any one help me understand this?

Also, I think the instructions for Bee.jsp are telling me to put another copy of jr.jar where tomcat needs to look - which differs from where I placed jr.jar to complete assignment OOP-1, correct??

Thanks.
- Dan
16 years ago

Originally posted by Carol Murphy:
the 3 class files are



So I am supposed to get 3 class files when compiling BeeServlets.java?? What are the names? I'm getting '$' in a couple.

Thanks.
- Dan
16 years ago
I just see the discrepancy now.

On http://www.javaranch.com/java-college.jsp
Assignment 2 is listed as Servlets-2 (ReverseServlet) in which case, the action attribute in the form tag is correct.

While on http://www.javaranch.com/drive/servlet/index.jsp
Assignment 2 is listed as Servlets-2 (Reverse), in which case the action attribute needs to be changed.

Thanks.
- Dan
16 years ago
I did not notice this anywhere in the forum - sorry if I'm reposting. Hope this is helps someone else.

For Servlet-2 be sure to notice that the html snippet for creating the form needs to have the action statement changed from ...

action='/servlet/ReverseServlet'

to ...

action='/servlet/Reverse'

Going with the convention from earlier assignments, the assignment title implies that the java class be called Reverse.class (not ReverseServlet.class).
16 years ago
Great - I've successfully compiled BeeServlet.java and see the results when I point my browser to the right spot. Thanks for the great help everyone.

While googling around for info about Tomcat I also came across JBoss and Sun GlassFish. From what I could tell, these all seemed similar, but not 100% overlapping. Any commentary on how these all relate would be very much appreciated.

Thanks!
16 years ago
I'm stuck at compiling the example BeeServlet.java.

Here's what I've got ...

- MacBook Pro running OS X 10.5.4

- Tomcat is installed and running. I see the intro page when I point Safari to http://localhost:8080

- The included servlet examples and JSP examples are working. For example, date is behaving as expected.

- java -version at command line returns ...
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-237)
Java HotSpot(TM) Client VM (build 1.5.0_13-119, mixed mode, sharing)

Now when I compile BeeServlet.java, the compiler complains that ...
package javax.servlet.http does not exist

The compiler error message makes me think I need j2EE - to have the correct packages - but I'm really not sure. After all, Tomcat is described as a servlet container - so why do I need additional packages? (I have search JR discussions and googled as well - and am still not sure.)

Thanks for any help.
- Dan
16 years ago
For OOP-4 (Lookup) ...

1. Is it OK to simply use 1,2,3, ... 12 as the serial numbers? Seems like doing so would keep nitpicker life moderately simpler.

2. The assignment only asks for a string of info about a particular item. My first thought is to simply use a long string of descriptive text for each item. (eg - "This is a book called blah, written by blah, which costs blah to rent , etc.") But this approach doesn't seem in spirit with the assignment purpose to learn all about polymorphism. There would not be anything really different from a video item and a furniture item.

So, I'm guessing I should really define a variety of relevant fields for each class, and build the text string from a particular instance of field values. Is this second approach more in keeping with the assignment goal?

Thank you very much.
- Dan
16 years ago


Whew! Got SortNames to work - and I feel GREAT! Wow, what an awesome example of the usefulness of an object approach. It took me quite awhile to work out how to properly fit my own classes into the larger java picture, but when I finally got the syntax correct, the amount of coding on my part was quite minimal. Very cool!

Very nice!
16 years ago
OK - got it. For some bizarro reason up in the method argument list, I had typed string1 and string2 as Objects, rather than String. Once I correctly typed each as String, it works fine.

Thanks!
16 years ago
I am returning int.

Isn't

intcompareTo(String anotherString)
Compares two strings lexicographically.


from the String Java doc the correct signature?
16 years ago