• 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

Passing web.xml info to servlets

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Help i'm stuck....trying to send information from web.xml to MyBasket.java servlet to SimpleShoppingBasket servlet. The information from the web.xml file is passed successfully to the first servlet, but all information (apart from quantities) are listed as 0 or null when trying to send to the second servlet.
I'm new to servlets so dont really have a clue what i'm doing!!! Could anyone help? I have included my code if anyone fancies giving me a few tips!!
FIRST SERVLET:
WEB.XML FILE:
SECOND SERVLET:
[ January 15, 2002: Message edited by: Mike Curwen ]
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Caroline, welcome to the Ranch.

I've edited your post to include the UBB [ code ] tags.

Here's what I came up with. First, I've modified your web.xml a little bit:

Then, your first servlet is modified thus: Then, your second servlet...
As for what you are doing in the second servlet, you are attempting to retrive from the request, the values that you had placed into your table in the first servlet. But these values are not IN the request. They are only 'plain HTML' as output by that first servlet.

If you want to retrieve the name and quantity and price, these need to be made form fields as well, so that when you POST to the second servlet, they are placed in the request as well.

I could also get into the whole discussion about architecture, databases and how init-parameters aren't the best way to be doing what you are doing... but thought I'd just answer your question.

You need to make everything you want to retrieve from the request (in your second servlet) a parameter on the FORM in the first page.
[ January 15, 2002: Message edited by: Mike Curwen ]
 
Caroline Harris
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the suggestions.....tried the 'hidden' types, but still didnt work!!
I must be doing something wrong! Do u have any other suggestions or links that might help me understand more?
Thanks
Caroline
 
Caroline Harris
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike...i read through my code again and i'd made a boo boo!! Typo!
Your suggestion did work. Thank you very much!
Caroline
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic