• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling "actions" problem with Servlets 4b

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ).
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
reply
    Bookmark Topic Watch Topic
  • New Topic