Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

page-transfer javabean problem

Status
Not open for further replies.

DoraC

Programmer
May 7, 2002
98
US
(sorry in advance for all the posts!)

As you can tell, I'm very new (< 2 weeks) to jsp/servlets/tomcat etc.

OK, I need to switch from one JSP page to a second one when a button is clicked. I can fire up a new page this way easily, by defining the button as part of an HTML form block. I just code something like
Code:
<form method=GET
      action=&quot;[URL unfurl="true"]http://2.jsp&quot;>[/URL]
and all works out well. However, I also want - upon the button being clicked - parameters from another component to be loaded to a javabean for usage in the second page, 2.jsp.
I load the bean as follows:
Code:
<input type=&quot;submit&quot;
       value=&quot;Transform&quot;
       onClick=&quot;
<%
       if ( request.getParameterValues( &quot;tables&quot; ) != null )
       {
%>
       <jsp:setProperty name=&quot;ParmHandlerBean&quot;
			property=&quot;lTables&quot;
value=&quot;<%= Arrays.asList( request.getParameterValues( &quot;tables&quot; ) ) %>&quot;/>
<%
       };
%>

where &quot;tables&quot; is a multiple-select input component in the same form as the &quot;transform&quot; submit button.

indeed, egregious bean-handling standard-violations aside,
this actually works when I fire up the second page NOT via the &quot;actions=&quot; as above, but with a page-open statement as part of the onClick parameter (appended to the code immediately above). However, the second jsp page is fired up evidently prior to the parms getting set in the bean - for it to display them I need to click twice (there's always that 1-click lag). The first page that pops up doesn't reflect the changes so I close it, re-click and the second one does. IF, however, I do it as above - via the action parm - they aren't recorded at all.

How can I do this? How can I load the parms into my bean AND launch the webpage (preferably not as a popup, but a page-transfer) AND have the new jsp page find the parms?
I've tried a lot of combinations of things, but so far to no avail.

Thank you...
dora
 
I'm mostly confused after reading your post but, if i am anywhere near getting it maybe you need all this code to run in 2.jsp rather than where it is.
Code:
<%
       if ( request.getParameterValues( &quot;tables&quot; ) != null )
       {
%>
       <jsp:setProperty name=&quot;ParmHandlerBean&quot;
            property=&quot;lTables&quot;
value=&quot;<%= Arrays.asList( request.getParameterValues( &quot;tables&quot; ) ) %>&quot;/>
<%
       };
%>

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top