• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
    • 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
    Author and ninkuma
    Marshal
    Posts: 65516
    105
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • 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
    • Quote
    • Report post to moderator
    @Bear

    thanks

    something this worked for me
     
    Kishor Joshi
    Ranch Hand
    Posts: 674
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    one more question is how to check Number of parameters in the request?
     
    J. Kevin Robbins
    Bartender
    Posts: 1801
    28
    Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
    • Mark post as helpful
    • send pies
    • 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
    • Quote
    • Report post to moderator
    I am doing some other parts related to JSP soon will update this post
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!