Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Beans > Re: submit butt...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 1254 of 1401
Post > Topic >>

Re: submit button in a jsp

by "anselm" <anselm.waigand@[EMAIL PROTECTED] > Oct 31, 2006 at 02:55 AM

=E6=96=B9=E5=8A=A0=E6=B5=A9 wrote:
> anselm =E5=86=99=E9=81=93:
> > I'd like to use a submit button without any form data, but rather with
> > my own data. I was thinking something along these lines:
> > <form action=3D"../servlet/ConfirmRasterServlet" method=3D"post">
> > <button type=3D"submit" value=3D"Confirm Raster">Confirm
Raster</button>
> > </form>
> >
> > when the user clicks on "confirm raster", arbitrary data (a hashtable
> > object from the jsp's request object for example) is sent to the
> > servlet.
> > Is this possible?
> > How do I set the data to be sent?
> >
> > thanks in advance!
> >
> I want to know too.
> Can somebody give me an answer?
> Thanks.

I've found a workaround, but if someone knows of a better solution,
don't hesitate to post it!
What I've done:
I've adde a hidden input field to my form

some.jsp:

<%

<pseudo-code>
put desired object into the session
</pseudocode>

String lId =3D "key to object";
%>

..=2E.

<form action=3D"../servlet/ConfirmRasterServlet" method=3D"post">
<input type=3D"hidden" name=3D"mapObject" value=3D"<%=3D lId %>"/>
<button type=3D"submit" value=3D"Confirm Raster">Confirm Raster</button>
</form>

when the user hits the button, "mapObject" and String lId are added to
the httprequest parameters. in the servlet the page is being forwarded
to, you can now access the object in the session that's associated with
the string "lId":

HttpSession sess =3D request.getSession(true);
String lId =3D request.getParameter("mapObject");
Object obj =3D sess.getAttribute(lId);

this is not really posting data to the servlet (at least I think it
isn't), but it works for now.
 




 4 Posts in Topic:
submit button in a jsp
"anselm" <an  2006-10-30 10:51:44 
Re: submit button in a jsp
=?UTF-8?B?5pa55Yqg5rWp?=   2006-10-31 12:43:23 
Re: submit button in a jsp
"anselm" <an  2006-10-31 02:55:00 
Re: submit button in a jsp
Lion-O <nosp@[EMAIL PR  2006-11-30 20:26:51 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 12:37:41 CST 2008.