• 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Jsp-page populated after succesful insert

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All,

I have a jsp page, to add new records to the database. Now, when the
records are added succesfully I have to come back to the same page with
the fields populated with the added values.

how do i achieve this ?

Please let me know.

Thanks
 
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your question is way too vague for a meaningful answer. JSP as a templating technology is designed to show live data on a page. So what aspect of that are you having trouble with?
 
Atul Mishra
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

Thanks for the reply.
let me be clear.

1. I have a JSP with fields/textboxes where user can enter a new record to the database. user types in the values and clicks submit on my page[1.jsp]
2. After user clicks submit, I have to show 1.jsp to the users with the same values they entered. I am coming back to the page, but the textbox values are empty.

As an example:

1.jsp, I have
FirstName:
LastName:
Address
textboxes

My user enters values in these textboxes and clicks submit.

After the record is insrted succesfully,
My textboxes should display the values the users typed.

Hope its clear

Thanks
 
Bear Bibeault
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use JSP mechanisms to populate the value attributes of the controls.
 
Atul Mishra
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

You mean use, scriptlets ?
I was trying to use the <bean:write tag provided by struts.

can you give me a sample please

Thanks
 
Bear Bibeault
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Custom actions are one of the JSP mechanisms. So yes, that's fine.

(I'd never urge anyone to use scriptlets).
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using Struts, you might be interested to know that we have a Struts specific forum here.
Say the word and I'll move this thread over there for you.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is struts, then it should almost take care of matters all by itself.
You should be using your Formbean to display the data in the form.

What scope is your formbean being stored in for this action (check struts-config)
Are you forwarding or redirecting to this "display" page. If redirecting, you will either need to retain the values in session scope, or read them back from the database in a "display" action.

Hope this helps,
evnafets
 
Bear Bibeault
Marshal
Posts: 67418
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the Struts forum.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use the <html:text> tag for your input fields, the values of those fields will be tied to the properties of the same name in the ActionForm bean for the page, and the values will automatically be populated when the page is displayed. You don't have to do anything to make this happen. If there's something you still don't understand about this process, let us know.
[ August 29, 2006: Message edited by: Merrill Higginson ]
 
Atul Mishra
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I use struts.

I have an html form[a.jsp], and the corersponding action class [asubmitAction.java]
I dont have a form bean. My jsp uses form action=*.do

struts-config file has the corresponding forward actions mapped

the fields in jsp are HTML form objects are <input type="textbox" name="" value=""/>


Action class does return mapping.findforward
I am setting the request.setAttribute property after succesful inserts in the action class.

So I have the fields stored in Request object after a succesful insert. My fields are stored in a "data" object.
[ August 30, 2006: Message edited by: Atul Mishra ]
 
    Bookmark Topic Watch Topic
  • New Topic