This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Cattle Drive and the fly likes Instructor's solution to servlets 3-a ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Instructor Watch "Instructor New topic
Author

Instructor's solution to servlets 3-a ?

Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1187
I'm trying to get everything set up on XP, and I'm going through the steps in Servlets, checking each assignment, to make sure each one functions. And for some reason, Servlets 3-a, reverse2, isn't working. I'm using the instructor's solution for the class files and the jsp file, and I get as far as the web page with the form, but it doesn't work. Nothing happens to the text entered in the form.
Any ideas?
It was working before, but since I adjusted things, it's not working now!
No error messages, just a dead submit button.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
Just off the cuff, I would suspect the web.xml first. After that, I would double check all paths in the jsp and the servlet.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1187
the jsp is in C:\Program Files\orion\default-web-app
the 3 class files are in C:\Program Files\orion\default-web-app\WEB-INF\classes\com\javaranch\drive
the web.xml has the servlet name and path (starting with com) input, but the link with the full path to the servlet doesn't work either.
The submit button is not active, or just not linked to the servlet as it should be. The path in the forward is "/nameOfJsp.jsp"
I'm confused, because it was working last night, but it isn't working now, and I don't understand what has changed. I downloaded ANT last night, and put it in my PATH variable, but I didn't take anything out.
I screwed something up somewhere, but I can't figure out where.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1187
This is really frustrating. From what I can see, both bee servlet and reverse2servlet are set up the same way. Package statements, path specified in both the jsp and servlets look right, the web.xml looks good, but my form isn't active. Maybe something wrong with the html? Checked that over, it looks good. Not good for my confidence! I'm totally stumped.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1187
Now I'm really confused. It seems that even though the method states it is post in the form tag in the reverse2 jsp, after 10/31/07 all I'm seeing are get requests in the default-web-access log. What could I possibly have done to cause that? I see plenty of posts up to 10/31/07, and now everything is a get!
I don't GET it?
I can see from the log that the Reverse2Servlet has been initialised and then destroyed, but why isn't post being used?
Has something changed in the jr.jar file? I do have the jrcommon-2-bin file in the lib folder in orion, but there are no source files in it. The only source files I can find are in the older copy of jr.jar I have saved. The older set is from 2006, the newer -bin version from 3/2007.
Any thoughts?
[ November 02, 2007: Message edited by: Carol Murphy ]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
Yes, adding Ant to your path shouldn't change the behavior of Orion. One red flag for me is that you have stuff in C:\Program Files. Having a space in your PATH/CLASSPATH is something I try to avoid at almost all costs. It frequently causes lots of problems.

"... it was working last night, but it isn't working now" is weird.

As far as jr.jar changes, the changes that were made wouldn't affect this at all. All the servlet stuff is the same in both of the jars that you mentioned.

Maybe adding ant to the path caused windows to suddenly notice the space in the path?? You've got me stumped.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1187
Yeah, this is really wierd.
XP wants to put every new program into the program files directory, and I just accepted the default. Maybe if I put all of my java stuff directly off of C:\ it would help, but that doesn't ecplain why it was working before, and why post gets changed to get!
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1187
I got it!
Apparently, when I copied the DOCTYPE tag at the top of the html I made 2 tiny typos at the end of the tag, and that made the browser send everything as a get request. Wow. The power of a missing 4 and a colon instead of double quotes!
Also, I had inadvertently left out the = after the word value. Which made the reverse thing not happen!
Whew! I thought my system was cursed on Halloween, or something worse!
Now, on to the next hurdle!
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
Omigosh! I would have never guessed. I'm glad you figured it out though.
John Abong
Ranch Hand

Joined: May 14, 2007
Posts: 79
Not that I know what I'm talking about here but it sounds like Marilyn nailed it right off the bat...
I would suspect the web.xml first
.

John Abong
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1187
Originally posted by john abong:
Not that I know what I'm talking about here but it sounds like Marilyn nailed it right off the bat... .

John Abong


Yeah, the funny thing about that is I was sure the web.xml had been cut-and-pasted from the instructor's solution, until I remembered I had printed it from my old system and typed it into the new one. My old system isn't connected to the internet right now because I gave my router to my son so he could get everyone's computers online in his house up in the city where he is going to school. (The sacrifices we make as parents!) When I remembered I had typed it by hand, I went back and checked everything line by line, and that's when I discovered the typos!
Doh!
I was surprised that the mistake I made in the DOCTYPE tag would have the effect it had on the way doPost and doGet were called, or not called, as the case may be. It seems my best learning experiences with coding come when I make mistakes and have to figure out what the heck I did wrong! The experience sticks in my mind for a long time.
[ November 15, 2007: Message edited by: Carol Murphy ]
Daniel Loranz
Ranch Hand

Joined: Jun 17, 2008
Posts: 41
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
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
It partly depends on which version of BeeServlet you're compiling... I do get 3 classes when I compile Reverse2Servlet.java

As far as the names, it depends. The compiler sometimes creates those classes with the dollar signs.
Daniel Loranz
Ranch Hand

Joined: Jun 17, 2008
Posts: 41
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
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
Are you talking about the very first BeeServlet?

This BeeServlet.java file will only create one BeeServlet.class file.

Or are you talking about the BeeServlet under the MVC section?



or are you talking about the one in between?


??
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
Getting more than one class from one file is not completely new if you've been compiling the instructor's solutions each time. Maybe even in your own solutions (although you probably didn't notice if you got one since you didn't need to do anything with it). Any time you have an inner class, the compiler will create at least one extra class -- with a '$' in it for the inner class. This is a good reason to avoid using a '$' in your own classes.
Daniel Loranz
Ranch Hand

Joined: Jun 17, 2008
Posts: 41
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Instructor's solution to servlets 3-a ?
 
Similar Threads
Email Issues
Servlets-5
pending assignment list
Well done Jason
Servlets-4a