• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Where to kick this off?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm quite a kindergarten schoolboy in the world of JSP and Servlet.

I find many things really hard to manage, for example,

I create a simple form:
<form id="blah" name="blah" action="Beer.do" method="post">.....</form>

I follow the example in the world's best book called "Head First Servlets & JSP" and it runs just fine.
As long as I wouldn't press enter directly to the url '...../Beer.do' in the address bar, everything is still fine.

Suddenly I do press ENTER and it's broken. I already delegate doGet to doPost and it seems like all parameters were lost in space.

What's the best practice to manage the control flows like ENTER@ADDRESSBAR, REFRESH, F5, CTRL+F5 , to force the web app runs smooth as I want?

Any suggestion on books or just the few keywords about design patterns will be really appreciated.

Thanks
Max
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have an

Inside your form, enter should submit the same as pressing the button.

The refresh / f5 problem is browser-related. Unfortunately, I am not sure you can control what the browser does on a reload. Just know that it will send the exact request as before.

EDIT:

I think I understand what you're asking. In the Beer.do servlet, you can add a doGet and forward to a jsp of your choice. That way when a user visits, it won't blow up.

As long as you understand that a GET request, handled through doGet will be used when a user types in an address or refreshes a page gotten to through a link and that doPost handles POST requests caused by submitting forms, then I think you have all the control you can get.

Sorry if my answer isn't really helpful, its a little hard to tell what you're asking.
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Be sure to properly control the caching of your responses. See the FAQ for details.
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic