• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

request.getAttribute("value") is not setting on input fields.

 
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there

I am confuse whethar to post this question on JSP,JavaScript or JQuery
But i am posting here
this is my code


but value are not setting on id "userId" although I am getting value and printed on console also but not on input field how to do this?

Thanks
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A couple of things.

  • Don't use Java scriptlets in JSPs. Especially not in JSPs where you are also using the JSTL and EL. What a mess!!!
  • Use proper naming conventions. getFirst_name() is not valid according to the bean naming convention. It should be getFirstName()
  • Once you do that, the value is easily obtainable with the EL via ${person.firstName}
  • Why are you trying to do it in JavaScript in the first place? The value is known on the server, just use JSP.


  • Don't make things harder than they need to be. You never need to put Java code into a modern JSP.
     
    Kishor Joshi
    Ranch Hand
    Posts: 674
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    ok here I have edited code on both jsp and model class bt still not working

    jsp code


    model class code


    and servlet doget method code


    but its still not working
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You still have Java scriptlets in the code. Why?

    You are still trying to set the value using JavaScript. Why?
     
    Kishor Joshi
    Ranch Hand
    Posts: 674
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    @Bear

    thanks

    something this worked for me
     
    Kishor Joshi
    Ranch Hand
    Posts: 674
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    one more question is how to check Number of parameters in the request?
     
    Bartender
    Posts: 1810
    28
    jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Kishor Joshi wrote:one more question is how to check Number of parameters in the request?


    request.getParameterMap() will get you all the parameters. That returns a Map. Check the Javadocs and see if you can figure out how to get the number of elements in a Map.

    And good job getting rid of the scriptlets. The next step is to move your JavaScript to an external .js file.

    And you need to change your href values and the "action" value to context relative paths. What's going to happen when you move your app to a new server?
     
    Kishor Joshi
    Ranch Hand
    Posts: 674
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I am doing some other parts related to JSP soon will update this post
     
    reply
      Bookmark Topic Watch Topic
    • New Topic