aspose file tools*
The moose likes Servlets and the fly likes How to bind data to a textbox in servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to bind data to a textbox in servlet?" Watch "How to bind data to a textbox in servlet?" New topic
Author

How to bind data to a textbox in servlet?

Soumya Rout
Ranch Hand

Joined: Aug 06, 2009
Posts: 49

Hi,
I have three textfields in one jsp page. In runtime user will put 2 values in the two textfields and in third textfield data from database. I have retrieved from database using a servlet and request dispatches to the same page. But how to bind the data to textfield.

Please help me out.

Regards from

Soumyaranjan
Karamjeet singh
Ranch Hand

Joined: Feb 24, 2010
Posts: 49

you can use this type by maintaing sessions between pages
by request.setattribute or by request.getattribute
bind value with setattribute
retrieve value where you want by getattribute


Don't aim for success if you want it; just do what you love and believe in, and it will come naturally.
Soumya Rout
Ranch Hand

Joined: Aug 06, 2009
Posts: 49

I know that, But how to assign that value to a textfield of that jsp page.
Karamjeet singh
Ranch Hand

Joined: Feb 24, 2010
Posts: 49

karamjeet singh wrote:you can use this type by maintaing sessions between pages
by request.setattribute or by request.getattribute
bind value with setattribute
retrieve value where you want by getattribute


sorry boss i don't understand your question please ignore previous post
for binding you can use this method
not sure for retrieval from database
Karamjeet singh
Ranch Hand

Joined: Feb 24, 2010
Posts: 49

you should put this like
<input type="text" value="<%=request.getAttribute("stringvalue")%>"/>
Soumya Rout
Ranch Hand

Joined: Aug 06, 2009
Posts: 49

Yes, that can be done.
thank you dude.
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 645
It would be better to use JSTL rather than JSP scriptlets. With JSTL you can write the same line as:
No scriptlet.

Best Regards,
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Mark E Hansen wrote:It would be better to use JSTL rather than JSP scriptlets. With JSTL you can write the same line as:
No scriptlet.

Best Regards,



That's not JSTL. That's the Express Language (EL).


GenRocket - Experts at Building Test Data
Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 645
Gregg Bolinger wrote:That's not JSTL. That's the Express Language (EL).


Uhhh, right :embarrassed: - sorry.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to bind data to a textbox in servlet?