aspose file tools*
The moose likes Servlets and the fly likes calling doGet(), doPost() on html page load Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "calling doGet(), doPost() on html page load" Watch "calling doGet(), doPost() on html page load" New topic
Author

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

seetharaman jayaraman
Ranch Hand

Joined: Feb 18, 2008
Posts: 43
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


Seetharaman Jayaraman
Only Change is Changeless
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

Well if you need to submit a form on page load, you can use this simple trick



You can also use this code



SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39537
    
  27
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?


Ping & DNS - updated with new look and Ping home screen widget
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 597

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?


Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
seetharaman jayaraman
Ranch Hand

Joined: Feb 18, 2008
Posts: 43
Hi all,
The below script solves the problem

Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calling doGet(), doPost() on html page load
 
Similar Threads
servlet
Doubts in HTTP Methods behaviour
Advantage of doGet method ?
ReverseServlet.java
how to load an image in a jsp