• 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

Parameters schmarameters

 
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
Okay, I can't get past this hurdle on my own. It's assignment 4b, Servlets. I've got my pages all hooked up and working as they should, which is great, my password page works, sends the password along, my session ID is being created, and everything seems ducky until I try to pass this parameter along to another servlet. It refuses to go, and I can't figure out why. The other parameters don't give this kind of trouble. Why is this particular one being so naughty? Any help or hints anyone can provide short of giving me the answer will be greatly appreciated by my family who are becomming increasingly concerned.........
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tell your family they shouldn't be concerned, you're just trying to sort out the messages the voices in your head are giving you...

Now with that out of the way, let's try to figure out where you are having the problem. Are you actually putting this session id/token as a parameter in a form? Make sure the parameter has a unique name, make sure the parameter's value is set to the token (hint: concatenation!), make sure when you try to retrieve the tokeN you are using the same exact name as the parameter.
What error messages do you get? Have you put in code that allows you to follow the progress of your program? I use System.err.println()'s a LOT, look in the log files for the output, unless Orion does things differently. Sometimes what I think is happening, or think I have certain data, turns out to be completely different.
[ April 30, 2002: Message edited by: jason adam ]
 
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
Thanks for your quick response! I'm running late for work because I've been obsessing over this. I created a textarea in each page that prints the same parameter as the one inside the hidden field. I get the desired results in the 1st form which is in the login page, the one that shows teh heading Logged In, but the parameters don't seem to want to be passed on to AddVideoServlet. the only value I get in that textfield is null. I will have a look at your suggestions when I return from work. the voices are telling me I have to go now.............
P. S. How did you know about the voices? I've never mentioned them to anyone before!
 
whippersnapper
Posts: 1843
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jason writes:
Are you actually putting this session id/token as a parameter in a form?
Click! Light goes on.
Carol --
I had been struggling to understand the different problems you've been having with this assignment.
Jason's statement above reminded me of a problem I had very early on in this assignment. Fixed it and moved on. Didn't make the connection until now that it sounds like the same problem you're describing.
Here's the point I was missing: depending on how you build your HTML page, you might need to write out the token more than one time on the same HTML page. But any time you do write out the token, it has to be inside a form. That means you might have more than one form on a single HTML page.
Double check your HTML to make sure that any time the token is being writen out it's inside a form, and that the form's method and action attributes are set appropriately.
(For example, you may want to place each of the buttons at the bottom it its own form. It's possible to have both buttons in a single form, but I think the code is clearer if the buttons are in separate forms.)
[ April 29, 2002: Message edited by: Michael Matola ]
 
jason adam
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Carol Murphy:
I created a textarea in each page that prints the same parameter as the one inside the hidden field. I get the desired results in the 1st form which is in the login page, the one that shows teh heading Logged In, but the parameters don't seem to want to be passed on to AddVideoServlet. the only value I get in that textfield is null.


You have to redefine the parameter with each pass through. You can't just set it on one page and expect it to be a parameter three pages down the road. As I understand it, you make a request, and that request gets the parameters that are set on the page you are requesting from. When you get to that new page, you can view the parameters from the previous one. However, once you click "next", "submit", whatever, a new request is generated containing only the parameters defined on the page you just requested from, the parameters from the first page are gone!

Originally posted by Carol Murphy:

P. S. How did you know about the voices? I've never mentioned them to anyone before!


Cause they told me about you having trouble and asked politely if I could help a little. I decided not to ignore them this time.
 
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by jason adam:
Tell your family they shouldn't be concerned, you're just trying to sort out the messages the voices in your head are giving you...
... make sure when you try to retrieve the toke...


the toke? Could this have something to do with the voices?
[ April 30, 2002: Message edited by: Pauline McNamara ]
 
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pauline McNamara:

the toke? Could this have something to do with the voices?
[ April 30, 2002: Message edited by: Pauline McNamara ]


hmmm... could this be a subconcious reflex?
 
jason adam
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have no idea what you two are talking about, my post looks absolutely fine
 
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you get rid of your problem if you let your servlets create ONLY ONE form containing the hidden token and all the buttons?
 
jason adam
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Peter speaks the truth. Inheritance plays a big role in the servlet programs (and other programs as well, of course), especially when you find yourself repeating HTML code.
 
Greg Harris
Ranch Hand
Posts: 1012
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by jason adam:
I have no idea what you two are talking about, my post looks absolutely fine


isn't the "edit" feature a wonderful thing?
 
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
First, thanks to all for your help.
Let's see, where to begin.....
My pages have more than one form because I created a different form for each function, like if a button is posting to a certain servlet, that button gets it's own form, mainly because I couldn't figure out how to make 2 buttons within the same form do different actions. Also, since the pages are supposed to resemble the examples given in the assignment, if a button belongs at the bottom of the page, then I can't put it with a form at the top of the page even if they do the same thing.
Now, as far as redeclaring the toke (or token, as the case may be ) on each page, this looks promising, as I was not doing so. I didn't realize that parameters were only visible one page deep so to speak. So I will pursue that path for awhile and see if I can get out of this maze!
And for now at least, the voices are being very quiet.
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Carol Murphy:

Now, as far as redeclaring the toke (or token, as the case may be ) on each page, this looks promising, as I was not doing so. I didn't realize that parameters were only visible one page deep so to speak. So I will pursue that path for awhile and see if I can get out of this maze!
And for now at least, the voices are being very quiet.


I thought, as per the assignment facts, that you create a token once and use it in as many pages as you like. So why redeclare it in every page? I too have been struggling on this one for quite a while now. Probably, I am interpreting things wrongly and missing something more staightforward here.
Secondly, about the parameters being visible only one page deep , I am not so sure. I created a token in VideoLogin servlet and used the same to check in AddVideo and ListVideo. Like Carol's voices there's a whole lot of mess in my head on this.
 
jason adam
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your token has to be in every page because each time you go to a new page, whether it be a page you already visited or not, you need to make sure the session is still valid. If you didn't, then you could access some pages without a valid session, which in my opinion constitutes a security risk (if this was actually a secure site type thing).
I'm playing around with the one page deep thing on request parameters, but from all my experience this is the case. I'll give an example later to try. Remember, if you set your classes up correctly, it might seem you are passing the parameter from request to request without hard coding it in the page, but that is in fact what really happens.
 
jason adam
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this, create an HTML page that has a form. The form has associated with it two input types. One is a button, it's method can be GET or POST, it's action goes to TestServlet. It also has a hidden input type named "test", it's value is "This test" (or whatever).
Now, create TestServlet to get the parameter "test", and output the value. Have your servlet also create a form for this page, but associate only one input type, which is a button. This will go to AnotherServlet.
Have AnotherServlet do the same thing, get the parameter "test" from the request. Output that result.
What do you get?
The request is simply a request for a new page. It will take with it parameters if they are there. Once you get to the new page, and then request another page, you are making a whole new request. The only things that get carried along with this new request is stuff that was defined in the page you made the new request from.
 
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
I haven't had a chance to try your test example, but I wanted to thank you for giving it to us. (My son is in a play next weekend and I have to work on his costume this week, so I am forced to take a short recess.)
Perhaps the distance will give me a better perspective!
 
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

Originally posted by jason adam:
Make sure the parameter has a unique name, make sure the parameter's value is set to the token (hint: concatenation!),
Jason;
I just now figured out what the reference to concatenation meant! DOH! I was working with the test servlet example problem you posted, and I had to go back to reverse servlets to figure something out, and the answer was sitting there smirking at me. Thanks for your help. Now I think I can submit another go at Servlets 4b in the very near future!

 
jason adam
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hehe, ain't that the way it always is?
Nice to know you figured the problem out, we'll be looking for your latest attempt posting at the Log!
 
Manju Jain
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jason, you were right. The parameter is visible only one page deep. I had it worked without redeclaring in each page because my AddVideo and ListVideo servlets inherited my mystery file where I had created the token variable. I hope I'm not giving too much away. But Marilyn said this may not prove correct for multi-user and multi-tasking purposes. She said I had to pass it [token] to other servlets to set it right. Without passing token around my inheritance strategy took care of making it visible in all other servlets.
I did use the hidden variable in each form but it always showed null even though view/source showed the hidden value to contain the token correctly.
Got to keep on working on it. And thank you all for valuable insights.

Sorry, I had to remove the name of the mystery file. --Marilyn
[ May 07, 2002: Message edited by: Marilyn deQueiroz ]
 
Manju Jain
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Finally, I believe I have got it right. Now if only Marilyn would agree
I was in real knots trying to pass the parameters between servlets. To anyone who is or may be in trouble, this is the 'Thread' which will help you untie all the knotty problems of Servlet 4b.
thanks all.
 
What do you have to say for yourself? Hmmm? Anything? And you call yourself a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic