Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to implement autofocus attribute  RSS feed

 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here i have a servlet where in inside of doPost i implement html form attribute.
The autofocus here is not working . y so ?

 
Author and ninkuma
Marshal
Posts: 66492
160
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that all you are generating? It's not valid HTML. Where are the html and body elements? Where is the doctype?
 
Sucheta Shrivastava
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
even when i write it like this it doesn't work .

 
Rancher
Posts: 3348
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you calling this servlet?
What URL are you using?

Is it another form doing a POST on another page?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66492
160
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66492
160
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sucheta Shrivastava
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear

here is he view source code :
 
Sucheta Shrivastava
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Dave Tolls

yes, it another form doing a POST on another page
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66492
160
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66492
160
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I loaded your HTML into three browsers: Safari, Chrome and FireFox on macOS and in all cases the name field attained focus.
 
Sucheta Shrivastava
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@bear . ok.it is an assignment i have to do. still learning advance java
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66492
160
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what is the problem? Just saying "it doesn't work" is meaningless.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!