wood burning stoves 2.0*
The moose likes Struts and the fly likes Jsp-page populated after succesful insert Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Jsp-page populated after succesful insert" Watch "Jsp-page populated after succesful insert" New topic
Author

Jsp-page populated after succesful insert

Atul Mishra
Ranch Hand

Joined: Jun 08, 2006
Posts: 140
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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Atul Mishra
Ranch Hand

Joined: Jun 08, 2006
Posts: 140
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Use JSP mechanisms to populate the value attributes of the controls.
Atul Mishra
Ranch Hand

Joined: Jun 08, 2006
Posts: 140
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Custom actions are one of the JSP mechanisms. So yes, that's fine.

(I'd never urge anyone to use scriptlets).
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1027
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
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Moved to the Struts forum.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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 ]

Merrill
Consultant, Sima Solutions
Atul Mishra
Ranch Hand

Joined: Jun 08, 2006
Posts: 140
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jsp-page populated after succesful insert