Forums Register Login
Unable to implement autofocus attribute
Here i have a servlet where in inside of doPost i implement html form attribute.
The autofocus here is not working . y so ?

Is that all you are generating? It's not valid HTML. Where are the html and body elements? Where is the doctype?
even when i write it like this it doesn't work .

How are you calling this servlet?
What URL are you using?

Is it another form doing a POST on another page?
OK, the 1st step of any problem is making sure that the HTML is valid to eliminate that as possible problem. So, that done...

Have you opened the browser's debugger and made sure that the page is delivered as expected?

And what exactly do you mean by "doesn't work"? Where is the focus?

And, why are you using a servlet for the view rather than a JSP? Is this a school assignment where you have to use a servlet? Or is this real-world code?
Something else that would be helpful.

When the page is displayed in the browser, do a View Source and post the result here. Be sure to use code tags.

here is he view source code :
@ Dave Tolls

yes, it another form doing a POST on another page
A POST should never result in a page being sent to the browser. Please read this article and pay special attention tot he descriptions of the PRG pattern.

After the POST, your response should redirect to the request that causes the page to be displayed.

And you still haven't answered my questions.
I loaded your HTML into three browsers: Safari, Chrome and FireFox on macOS and in all cases the name field attained focus.
@bear . ok.it is an assignment i have to do. still learning advance java
So what is the problem? Just saying "it doesn't work" is meaningless.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards

This thread has been viewed 601 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 16, 2018 02:36:19.