aspose file tools*
The moose likes Cattle Drive and the fly likes Calling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "Calling "actions" problem with Servlets 4b" Watch "Calling "actions" problem with Servlets 4b" New topic
Author

Calling "actions" problem with Servlets 4b

Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
I am having trouble calling different "actions" from my application. In init(), I've got three different actionHandlers. However, I can't seem to be able to call them when I need to. For example, I have a default, addvideo, and submit video "actions". But the only way I can get one to run is to list it as the first action. It's kinda like the server looks at the first "action" listed and uses it if it's first, but if not it goes ahead and used the first one as the default, even if it's not called "default". The only way I could get the instructors solution to work was to move the 'submit a video' action to the top of the list. But it seems to me that I should be able to call any action as I see fit. But so far, I haven't had much luck doing this.

FWIW, Marilyn, I had this same problem with my code for VideoServlet.java (as opposed to the instructor's solution for 4a like I was supposed to use).

Any ideas, help, thoughts would be greatly appreciated!
Nick White
Ranch Hand

Joined: Oct 09, 2006
Posts: 94
Matt

I am way behind - and I can only offer my support, rather than technical ability.

However, what I have noticed is that the nitpicks although they may seem harsh, gently nudge you in the correct direction. I assume you have received a nitpick from one of the ladies, and I know they will have helped. Did your first attempt actually work? - I assume so, if this is the case, read the nitpick and think....

I would love to be able to help more, and I know you have been through what I am trying to go through, but 4a and 4b take quite a few hours to sort out.

I guess it just gets harder.

Use the instructor's solution from Servlets-4a as your base for this assignment


I assume you have this in mind?

Good luck Matt I am looking out for you.

Regards

Nick
Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
Thanks for the reply, Nick. Yes, I'm using the instructor's solution verbatim. My first solution works and I can get this one to work, but not like I think I should. I could be way off-base here, but it seems to me you should be able to call specific "actions". I'm sure I'm just missing
something obvious like I usually am

I guess it just gets harder.


You can say that again. But it gets more rewarding when you get it right as well.

NOTE: I probably won't respond any more to this thread for a few days. I'm going on a mini vacation and won't log on for a day or two. But please feel free to post away (just don't get too specific and get it pulled ).
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12
It's kinda like the server looks at the first "action" listed and uses it if it's first, but if not it goes ahead and used the first one as the default, even if it's not called "default".


I'm not quite following you here, but the key is that if you call an action, and the init() method doesn't have an action by that name, it will use the first action in the list as the default action (even if it's not named "default").

The only way I could get the instructors solution to work was to move the 'submit a video' action to the top of the list.

Did you do a clean deploy? Sometimes old jsps hang around and mess things up. If you are using the instructor's jsps and the instructor's VideoServlet, it should work as you expect.

You know that you can look in the orion directories and see which jsp is actually there, right?


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: 1199
Matt, I had similar experiences with this. I'll have to go back and look at my posts to remember exactly how it resolved, but if memory serves, (and lately it usually doesn't) it has something to do with the way the actions are coded. There's a subtle difference, if I recall.....
Will research this more this afternoon when I get back from town.
Matt Fry
Ranch Hand

Joined: Mar 06, 2006
Posts: 60
I think I've got it now. I kinda started over this morning by deleting my old stuff and starting from scratch with the instructors solution. It worked fine.

I've ran into this problem before so I don't know if it's some subtle coding/syntax issue or if I had "ghost" jsp's or something floating around causing the unexpected behaviour. When I cleaned out the "c:\java\videos\src\web" directory and started from scratch, it worked right off the bat. But it really had me scratching my head a few days ago.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1199
Glad you got it working, Matt! I checked my posts on this and my problems stemmed from a difference in the name of one of the actions in the addvideo.jsp. The most current version has 'add a new video' where the archived version was 'add a video'.
This caused me a lot of grief until I figured out what was going on.
The first action listed being the default action regardless of its name was one surprising thing I discovered too, but when I learn by running head-first into a brick wall, it tends to stick better than when I stumble onto it by serendipity!
Happy coding!
 
 
subject: Calling "actions" problem with Servlets 4b