• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Servlets-4a

 
village idiot
Posts: 1207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am struggling (well, floundering, really) on this one. I have decided to work on the table format first, and I am trying to get the given list of videos which is stored in an ArrayList to print out in the cells of the table, as they are in the example.
I have banged out a few lines of code for the MysteryFile, where I put the ArrayList, and some more code for the ListVideoServlet. The code compiles with no trouble, but when I try to look at the page on the browser, the server is giving me this error message:
500 Internal Server Error
java.lang.NoClassDefFoundError:MysteryFile
at ListVideoServlet.doGet(ListVideoServlet.java:27)
at ( then ther are about 9 more other places named )
What can I do to fix this?
 
tumbleweed
Posts: 5089
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carol did you copy your compiled classes to the c:\orion\default-web-app\web-inf\classes ?
the above assumes you installed orion to your c:\ drive
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to what JdJ said (which sounds like it could be the problem), one thing I noticed is that you are using doGet(). I was told this is not a good thing, because doGets allow people to view the information your servlets are passing (for example, the password stuff). Instead, you should be overriding a method in one of the servlet classes in com.javaranch.common (your servlets should extend this class).
 
Carol Murphy
village idiot
Posts: 1207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmmm..... I did put my class files in the class folder, but that was after the message first appeared. Perhaps my good ol' browser was still loading the old message after I did that. As far as doGet() not being safe, I so do not get this servlet stuff at all yet! I feel like I'm stumbling around in the dark in an unfamiliar room full of wierd stuff looking for the light switch, which may not be there! Any way, I think I will try to get something that works first, then I may feel strong enough to make it secure!
By the way, doGet() doesn't make sense to me. What exactly is doGet() getting? Is it a request for the address of a html document, or is it the information supplied within the document, or both? doPost() makes a little more sense, but I am really confused right now!
 
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
doGet() or doPost() is what you are doing to the HTML page or Servlet that you are calling... your form can have a couple different methods:
< form method=get >
< form method=post >
so, if i understand this correctly, whatever method you give to your form determines which method is called in the servlet?
 
Sheriff
Posts: 9099
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some people have discovered that (particularly with Internet Explorer) you need to stop Orion and restart it everytime you make a change to your files in order to see the changes.
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's part of it. Another distinction is how these files can be called. doGet() can be called from a form, from java code, or just from the browser by default. doPost() can only be called from a form or from java code.
This means that if you just type http://localhost/servlets/AddVideoServlet into the browser, AddVideoServlet's doGet() method will be called. To my knowledge, there's no way to call a doPost() method this way. This also means that doPost() methods are protected from access from bookmarks.
 
Marilyn de Queiroz
Sheriff
Posts: 9099
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need doGet to get a page if you just type the url into the "Location" (NN) or "Address" (IE).

You need doPost if you press a button and pass information into the new page like a "title" or a "password" or a "phrase to be reversed".

 
Carol Murphy
village idiot
Posts: 1207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sooooooo befuddled by all this! Language doesn't work for me sometimes. I just have to understand the concepts without using language! (Does that make any sense?)
 
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just starting to get my feet wet with servlets, but came upon this thread in the servlets forum: http://www.javaranch.com/ubb/Forum7/HTML/007007.html
Maybe it can help a little. It has links to other threads too. They all have language though, unfortunately.
Direct enlightenment would be much more convenient, easier on the eyes, too.
Hang in there,
Pauline
 
jason adam
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're correct in that Greg, whatever you set your form to is what you will call in your servlet. Get those mixed up and you start getting funky stuff.
Carol, the tip about not using doGet() was not really to focus on the technical aspect of why it isn't secure (Marilyn has explained that part above), but instead to move you more towards a better solution. Whatever you do, take your time. Servlets can be perplexing, don't lose any sleep over 'em
In regards to stopping/restarting Orion, I always have to do that (running W2K, use IE... though I sure the heck wish I knew another OS well enough to be on something different) when I make any changes to a class file. Otherwise, it still shows what used to be there, even though I have copied over.
 
Greg Harris
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
something i have noticed about restarting orion is that i can recompile an edited servlet and run it without restarting... but, if that servlet has to access a flat file (.txt, .dat...) i need to restart.
(of course, i could be crazy)
 
Carol Murphy
village idiot
Posts: 1207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think we're all a little crazy!
Marilyn, you nailed it. I have to close orion and restart to see any changes.
JDJ- you were also right, I was using older copies of my class files, so I had to put the updated versions in there! Doh!
Everyone else, I think I'm starting to get it, although I'm still using doGet() for the time being. I do have a working AddVideoServlet and it passed the title of a new movie to my ListVideoServlet! (I'm only working with that one parameter until I stop banging my shins in the dark)
Now I just have to figure out what in the heck is goin' on here!
Once again, thanks for all of your hand-holding and support.
    Bookmark Topic Watch Topic
  • New Topic