Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling doGet(), doPost() on html page load

 
seetharaman jayaraman
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a html page which has one submit type button. on clicking this button, a request is sent to server side to invoke doGet(), doPost() methods. Here, How to eliminate or bypass the button click process. i.e. on completing the html page load, automatically the button click event should fire (instead of clicking on the button manually). I want to bye pass this html page and want to call the servlet directly.

please suggest/help

bye for now
 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well if you need to submit a form on page load, you can use this simple trick



You can also use this code

 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is the web app serving a page that the user is not supposed to see or interact with in the first place? Instead of going through the response->request->response cycle, wouldn't it be easier to do whatever should happen in the first response?
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use javascript.

Here is a really bad way to do it.



On first thought why do you want to do something like this? Why create a page having just a single button?
 
seetharaman jayaraman
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
The below script solves the problem

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Terrible. Highly terrible. This is simply a very bad practice. You shouldn't even think about it.

Just let the url-pattern of the servlet cover the request url. Then its doGet() will be called. That's all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic