Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I don't doGet() it!

 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Servlets 4b there is a puzzle I can't solve in the AddVideoServlet class. This servlet is supposed to display 2 different pages, as I gather from the sample browser pages in the assignment itself. The first page should display the form and the second page displays a message that the video has been added, along with 2 buttons for adding a video or looking at the list of videos. I thought I had this figured out by using doPost to display one page and doGet the other, but now I am getting my sensitive parameters displayed in the address bar from the doGet page. Calling doGet() from inside doPost() just makes the two pages appear at the same time, which I don't want to happen, and the parameters get shown anyway! What's up with that?
 
Manju Jain
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use doPost to display both the pages. Divide your method into 2 parts with the help of conditional statements. Just evaluate when you'll need to display the main form or the new video added page.
Hope this helps. I don't know whether giving more hints would be appropriate.
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to use both doGet() and doPost().
 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your responses.
Manju- I was thinking that was how it would have to be done, but having trouble coming up with a way to do it.
Marilyn- I think I was just being lazy by attempting to build on my previous code instead of starting fresh on this assignment. Back to the drawing board!
 
Peter Gragert
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I checked which button was pressed ...
 
Manju Jain
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carol, initially I faced the same problem. I tried using a static global variable but it was inadvisable by Marilyn. And then I found a way using if else.
Hint: Use removed code first before displaying any of the pages.
[ June 03, 2002: Message edited by: Pauline McNamara ]
 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter-did you do that with javascript, or is there a way to check which button is clicked using html or regular java code? This question has me stymied.
Manju-I don't see how you can submit the data from the first page to AddVideoServlet and then display
the second page all from doPost() ......wait a minute, if you can check to see if all fields have been completed, then you should be able to display the second page as well, right? I have a page with no links that displays if a required field is left blank. I wonder if the title bar for that page reads AddVideoServlet! Aha! But I can't check right now because I am on the computer at work, and my programs are at home!!! RATS!!!
P.S. Thanks!
[ June 01, 2002: Message edited by: Carol Murphy ]
[ June 01, 2002: Message edited by: Carol Murphy ]
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No javascript (I don't know javascript). Your buttons have different names and different values.
 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, my buttons didn't have names, although they did have values. Now that they have names, I think I can solve this problem!
 
Peter Gragert
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Indeed no javascript here. The "different" buttons are indeed the clue
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic