wood burning stoves 2.0*
The moose likes Cattle Drive and the fly likes Need Servlets 4a Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Need Servlets 4a Help" Watch "Need Servlets 4a Help" New topic
Author

Need Servlets 4a Help

Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
O.K. This servlet stuff is really kicking my tail. I've spent the last week trying to learn and make more since of these things. Ant in particular causing me some grief. I can't seem to get a handle on how it sets things up to be displayed in (or called by) a browser.

When I type "ant ffbuild deploy" from within c:\java\videos, Ant does its stuff and eventually says it was successful. However, I can't seem to get anthing to come up. It's like it's not deploying anything. I can manually put an index.html page in orion's default web folder and display that (with a slightly modified URL), but I can't get there by using Ant and then typing http://localhost/videos/VideoServlet.

Here's the relevant directory structures is this helps any:




But, in c:\orion\applications, there is no videos folder like there is with bee or reverse.

Any help with this would be greatly appreciated. I had a lot of trouble with ant on the last assignment so that makes me believe Ant is causing the trouble now, but I don't really know.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
ant ffbuild creates the war file in the /build/dist directory.
ant deploy takes the file and copies it into /orion/application directory.
Then, when you start orion, orion will "explode" that war file into the directory structure you need.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
So if I type into a brower, http://localhost/videos/, I will be redirected to an "index.html" file that has a link for "/videos/addvideos.jsp"?

My problem is I can't get anything to come up in a browser window. Everything seems to run fine w/ "ant ffbuild deploy" prompts. No obvious errors that I can find. Everything looks OK in build.xml and web.xml.

Here is the output from jar tvf videos.war:




I'm going to keep on reading because I know there's some fundamental chunk of knowledge I'm missing, but I would appreciate any clues or pointers in the right direction.

Thanks!
[ August 29, 2006: Message edited by: Matt Fry ]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
What does web.xml look like? (inside)
And the two files that you changed in orion's config dir?
Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
That was it, application.xml. :roll: I shouldn't have missed that.

Thanks, Marilyn!
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Glad you discovered the problem.
Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
Time for another question:

I have been reading all the past threads about this assignment looking for clues and either I'm really confused or the assignment has changed. The older threads mention a "mystery file" and/or more than one servlet. Please correct me if I'm wrong, but the instructor's solution for this one calls for only ListVideos.jsp and VideoServlet.java (in addition the other files that can be downloaded).

So, I'm assuming that all we need is the additional jsp and java file. So, the user types: http://localhost/videos and is brought to a static html file with a link to addvideo.jsp. This form, when filled and posted, sends the data to VideoServlet. VideoServlet takes the data, enters it into an object and inserts the newly created object into an array list. Then, VideoServlet passes the ArrayList to listvideos.jsp (somehow) and it pulls the elements out of the array and uses them to build the table. Is this correct (or even close? If so, how do I pass an array to the jsp? I've tried several ways and none have been successful. All I've been able to successfully send to a jsp has been Attributes (via request.getAttribute).

I appreciate any help with this!
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1195
Originally posted by Matt Fry:

All I've been able to successfully send to a jsp has been Attributes (via request.getAttribute).



There's your clue! I have to tell you, if you look at my posts from this very assignment, you'll find I had the exact same question. You already know the answer, if you think about it..................................
(Wait till you get to the next half of this assignment. I'm totally stuck, and I'm sure I'll still be slogging through it when you've caught up to me.)
Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
Thanks Carol, I appreciate the reply! I tried "wrapping" it as an object and passing it using send(servlet , object) but I couldn't get it to work. Am I on the right track here with this or am I missing something obvious?

Thanks again for the advise!
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
Yes, Matt, you're on the right track. You need an ArrayList and you use attributes. The servlets assignments have changed considerably since they were first created.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1195
I found this discussion from when I was where you are. I don't think it will give the answer away, but you will have to dig a bit to find the relevent post! Have fun!
http://www.coderanch.com/t/289803/JSP/java/annoying-expression
Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
Thanks Marilyn and Carol, I really appreciate it. I worked on it some Saturday and yesterday and, although I still don't have a working solution, I feel I'm getting much closer. Since it's a holiday, I'm going to wait until tomorrow before I work with it anymore.

What was really confusing me was how to pass an arraylist to the jsp. If I'm understanding what I'm reading correctly, you just pass it like any old attribute and then cast it back to an array list when you pull it out in the jsp (or wherever). Is this correct?

What was hanging me up was I was thinking you could only pass text/strings (or perhaps objects using another method - but I couldn't get that to work at all) via attributes. So, can you pass anything (array, hashmap, linked list, etc) like this and then cast it back out?

Thanks again for all your advise!
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1195
Originally posted by Matt Fry:

What was really confusing me was how to pass an arraylist to the jsp. If I'm understanding what I'm reading correctly, you just pass it like any old attribute and then cast it back to an array list when you pull it out in the jsp (or wherever). Is this correct?

Almost. There's no need for casting in the jsp.


I was thinking you could only pass text/strings via attributes.



There's your clue!
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
I think that, for this assignment, it is easier if a String is passed to the jsp.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need Servlets 4a Help