Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Seeting default value in form input tags

 
jas preet
Ranch Hand
Posts: 78
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have form input tags ...
I want to set a default value such as ${UserName} to it .
Please suggest . i could not find any way out .
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jas preet wrote:I have form input tags ...
I want to set a default value such as ${UserName} to it .
Please suggest . i could not find any way out .


In the request for the form in the first place, the Get add the object to the Model.

Usually you have a Controller with multiple methods. One method is mapped to the GET request and one to the POST request.

In the GET request method add the backing object of the form to the Model and return it.

Then in the jsp web page use ${backingBean.propertyName}, then when the submit button is mapped to the POST method the backingBean passed in as a request parameter you can access the values through that parameter object.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic