Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Shopping cart servlet error  RSS feed

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i have been working on trying to make this shopping card java program. First I tried doing requestmapping and parameters but after looking online I found some other ways that used servlets. While working on this code and running it, the index page is fine but when i press add to cart i get the white error page. I dont know where the logic could be wrong, any help would be great.



My cart page



and my html code

 
Sheriff
Posts: 23696
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That white error page: is it just a plain blank white page or does it have some information about an error?

If it has information on it, then it would be helpful if you posted that information, for anybody who wanted to answer your question.
 
Henna Ghayas
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the error message I am getting

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Wed Apr 04 15:29:50 EDT 2018
There was an unexpected error (type=Not Found, status=404).
No message available
 
Paul Clapham
Sheriff
Posts: 23696
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aha. So action="Addtocart" doesn't lead to your servlet, it leads nowhere. So check your configuration to see why that is. (From what you posted, I can't tell whether you used annotations to configure that servlet or whether you used a web.xml file). Also make sure your servlet is in a package, as servlets which are in the default package (i.e. don't have a package declaration at the top) won't work.
 
Saloon Keeper
Posts: 4744
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also note that it's bad design to use a processRequest method that is called by both doGet and doPost. GET and POST are not interchangeable, and be used in different circumstances.

Adding something to a shopping cart should be done via POST, so you need to add that to your form declaration.
 
Henna Ghayas
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, i actually got it to work by your suggestion of the xml change
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!