I think what you're missing are two fairly big fundamentals of JSP's:
beans != servlets
jsp's become servlets when compiled
Beans provide getXXX() and setXXX(...) methods to servlets and JSP's to
be able to maintain state. Beans also provide non-set/get methods to do
useful actions like committing themselves to a database or performing
some sort of ugly calculation.
So, even if your bean has a processRequest(...) method, it will never
get called, uness you include something like the following after your
<jsp:useBean />:
<% registerbean.processRequest(request); %>
Note that you can use the id from your useBean tag just like a variable
-- because it is.
I would argue, however, that having a processRequest method in your bean
is the wrong approach. A better solution would be
<jsp:setParam name="registerbean" property="*" />
This way, the JSP engine does all the work that your processRequest(...)
method would have to do. It finds all parameters in the HTTP POST/GET
that match method names in your AMCreg.register class, does all the
necessary integer/double/boolean parsing, and calls the appropriate
setXXX(...) method to change the bean's state. If you chose to write
this yourself, you're asking for an awful lot of work and maintenance
whenever you add another property to your bean.
-=- D. J.
Rob Fahey wrote:
> I am including the bean on the page as follows:
>
> <jsp:useBean id="registerbean" scope="session" class="AMCreg.register"
> />
>
> I want to process all the data sent from a form on the previous page
> (thats quite a lot of data) in this beanlet. However, because it's a
> general purpose processing class, I don't know exactly what the fields
> in the POST/GET data will be... Hence, I have written a procedure into
> the beanlet which should process the request object, extract the data
> from it and store it in the Session object for later processing.
>
> public void processRequest(HttpServletRequest request) {
> ... do stuff ...
> }
>
> Now, to my mind, based on my knowledge of general servlets, this process
> should be called as soon as I instantiate the beanlet on the page.
> However, as far as I can see, it isn't called at all... (I have debug
> lines in there which don't produce any output, which tells me that the
> method is never accessed).
>
> My question is, what am I doing wrong...? And am I approaching this in
> the right way in the first place? I have assumed all along that JSP
> beanlets have full access to the HttpServletRequest object... am I
> correct in this assumption?
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html