0

(netbeans latest, windows 7)
So, from what I understood, once I start a servlet program
the html page with a form in it loads and I can debug the program only when I click the Submit button
at the end of the form.

if the form is doPost then by using the doPost function.

Now , if I would like to get into the servlet functions instantly when the
html page load ( in order to check for sessions and such)
how can I do it with using java commands?
( ** like the doPost but without the need to click any submit button** )

everything I googled was related to javascript or weird commands in the html that I dont understand

Thanks again,
Despairy

2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by Despairy
0

Servlet technology is based on request / response model.
When user requests something to the server by sending an HTML request.

In the current case user can place a "get" request for the HTML page and server sends the htmlpage which is displayed on the client's browser.

So now after page is loaded on client's side(on browser) it is the client who is having control of the page and server does not know what is happening at client end on the HTML-page.
The server will be notified only after user clicks the submit button on the HTML page
Here client is sending a post/ get request again to the server.

Hence if you want to debug on the HTML page served on client side you need java script.

If you need more details , you can start your applicaiton server in DEBUG mode and verify the server logs for more details.

0

Well I did manage to do what I needed using the following code:

<SCRIPT LANGUAGE="JavaScript"><!--
setTimeout('document.sessions.submit()',0);
//--></SCRIPT>

But I was wondering if I can do so without javascript and only handling the servlets files.
As you said the control of the page is by the user , is there a way I could give
the control to the servlet and not the user but still the user will be able to submit
stuff?

Thanks for the informative response :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.