i'm trying use submit button pass 2 parameters, userid
, friendid
, using jsp same servlet. able obtain friendid
, however, not able obtain userid
.
function anotherpageservlet(servletname) { document.forms[0].method = "post"; document.forms[0].action = servletname; document.forms[0].submit(); } function anotherpageservlet1(servletname) { document.forms[0].method = "post"; document.forms[0].action = servletname; document.forms[0].submit(); } <input style="color:#3333ff" type="submit" class="rsubmit" value="<%= retrieving.getdisplayname()%> :" onclick="anotherpageservlet('viewingfriendservlet?stringparameter=<%= session.getattribute("userid") %>'), anotherpageservlet1('viewingfriendservlet?stringparameter=<%=retrieving.getoid() %>')" >
you need escape quotes:
onclick="anotherpageservlet('viewingfriendservlet?stringparameter=<%= session.getattribute(\"userid\") %>'), anotherpageservlet1('viewingfriendservlet?stringparameter=<%=retrieving.getoid() %>')"
i'm not used jsp, in jsf rather assign values request-scoped bean , call function works bean, rather passing arguments directly.
edit:
define onclick functions first, call simple reference.
function servletfoo() { anotherpageservlet('viewingfriendservlet?stringparameter=<%= session.getattribute("userid") %>'); anotherpageservlet1('viewingfriendservlet?stringparameter=<%=retrieving.getoid() %>'); }
then in html:
<input ... onclick="servletfoo()" />
Comments
Post a Comment