(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,

Recommended Answers

All 2 Replies

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.

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

<SCRIPT LANGUAGE="JavaScript"><!--

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

Thanks for the informative response :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.