aspose file tools*
The moose likes JSP and the fly likes help needed with  jsp:getProperty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "help needed with  jsp:getProperty" Watch "help needed with  jsp:getProperty" New topic
Author

help needed with jsp:getProperty

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Hi

I'm building a website, there is a JSP that collects user information
which when submitted, takes you too another JSP, which puts this information into a bean.
The problem is, I want to be able to use the properties of a bean.

Firstly, I cannot seem to use left(less than) and right(more than) arrows in this thread, so I'm letting L and R be the left and right arrows respectively.

For example, if I wanted to initialize the String NAME with "QWERTY",
I just type into the JSP L%! String NAME="QWERTY"; %R
So how could I store Ljsp:getProperty name="details" property="first" /R
into NAME instead of "QWERTY"??? ANY IDEAS
[ August 04, 2005: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

which when submitted, takes you too another JSP, which puts this information into a bean.
The problem is, I want to be able to use the properties of a bean.


Simplify. Simplify. Thoreau was a wise man!

If you are submitting directly to a JSP page, and want to use the submitted parameters in scripting variables, why go through all the bother of creating a bean?



Do you have unstated reasons for collecting the information into a bean?

And yes, you can post code with angle brackets as I did above. There are some phrases that the UBB software doesn't like though -- usually "javascript-y" type things.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Hi, the reasons are fairly straightforward, I need to collect some user information in a JSP, then in another JSP(or servlet) check that all the fields are non-empty and of the correct form, if they're not, I need to go back to original JSP to re-enter information.

If all the information is correct, then I can use a bean to put this info into an excel spreadsheet (in a servlet)
Yuriy Zilbergleyt
Ranch Hand

Joined: Dec 13, 2004
Posts: 429
For example, if I wanted to initialize the String NAME with "QWERTY",
I just type into the JSP L%! String NAME="QWERTY"; %R
So how could I store Ljsp:getProperty name="details" property="first" /R
into NAME instead of "QWERTY"??? ANY IDEAS


Wait, are you trying to retrieve the the value from the bean, or set the value in the bean to what was submitted? Or both?

-Yuriy
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

then in another JSP(or servlet) check that all the fields are non-empty and of the correct form, if they're not, I need to go back to original JSP to re-enter information.


So why aren't you using a servlet? Using a JSP to do anything other than render a view is like using a wrench to drive a nail.
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Hi, I need to check the information that was previously submitted is in the correct form,
I can do this ok, by using request.getParameter(...), but not sure if I need to use a bean, so that when the user has missed some information, he goes back to the jsp and the partially entered fields are still there.

Assuming, all the information has been sumbitted correct, I know how to put this into a bean, but not sure how to get the information into a seperate servlet(excel file) to be looked at later.

i'm going slightly mad, any help is welcome
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

While there are many ways to do what (I think) you are trying to do, the high-level mechanisms could be something along the line of:

1) The form is submitted to a servlet whose purpose is to process the form data.

2) The servlet validates the data. Whether it does this directly, or whether it delegates the validation to an abastraction of the submitted data (a bean, if you will) is up to you. I tend to favor the abstraction approach.

3) If validation succeeds, the servlet goes about its merry way processing the data. If you've gathered the data into a bean, that's the way the data can be carried along through its subsequent processing.

4) If validation fails, the servlet forwards back to the submitting JSP. Since the request is forwarded, the request parameters are still available on the request and can be used to initialize the form fields using the value attribute of the form elements.
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
OK, I've managed to get all the information from the submission form,
and enter it into a bean. I need this bean information stored in a servlet(as an excel file).
Basically, for each user, a bean collects their information, and this needs to be stored in the servlet. Not sure exactly the best way to do this, will do some reading now.
Any help is appreciated
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

stored in a servlet(as an excel file).


You're going to have to expound on what you mean by this. The term "stored in a servlet" isn't very meaningful. Do you mean "stored in an excel file written by a servlet"?
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
Yes stored in an excel file, produced by a servlet,
using the content type application/vnd.ms-excel

I'm using the core Servlets and JSP by Marty Hall and Larry Brown,
but I can't quite get my head around it yet.
[ August 04, 2005: Message edited by: colin shuker ]
 
jQuery in Action, 2nd edition
 
subject: help needed with jsp:getProperty