Win a copy of Microservices in Action this week in the Web Services forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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 ?

 
Marshal
Posts: 67166
169
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: 3771
40
  • 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
Marshal
Posts: 67166
169
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
Marshal
Posts: 67166
169
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
Marshal
Posts: 67166
169
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
Marshal
Posts: 67166
169
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
Marshal
Posts: 67166
169
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!