=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.


|