Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Where to kick this off?

 
Pakawat Gibson LP
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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
 
Brian Henk
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65542
110
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be sure to properly control the caching of your responses. See the FAQ for details.
 
Willie Smits can speak 40 languages. This tiny ad can speak only one:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!