Hi, You can't mix jsp into your javascript for the simple reason that jsp is server side, ie the jsp code is compiled and executed on the server before the page is sent to the browser, whereas javascript is client side, the javascript is executed by the browser on the client machine. Writing jsp (such as <jsp:forward>) to the webpage using javascript can't work because the webserver needs to interpret the command on the server, before handing over the page.
Your javascript should work though if you leave the jsp out and just use the javascript 'location' , as in function deleteMaterialFromList(materialId) { var agree = false; agree = confirm('Something intellagent...'); if(agree) { location = "/project/remove.do?material=\""+materialId+"\"; } else { location = "/project/prepareUserHomePage.do"; } } > I'm relatively new to all this and have been having a problem recently. > I've got a list of items on a users homepage that has a delete link next > to it. When they click on that they get a javascript confirm dialog asking > them if they really want to go ahead. > > In the jsp file I've got: > > function deleteMaterialFromList(materialId) { > var agree = false; > agree = confirm('Something intellagent...'); > if(agree) { > document.write("<jsp:forward > page=\"/project/remove.do?material=\""+materialId+"\" />"); > } > else { > document.write("<jsp:forward > page=\"/project/prepareUserHomePage.do\" />"); > } > } > > and later: > > <a class="delete" href="#" onMouseOver="status='Remove this material'; > return true;" > onmouseout="status=''; return true;" > onclick="deleteMaterialFromList('<%=mat.getName()%>');">X</a> > > But all it does is display a page of text with that one line on it. I was > expecting it to forward to the action and produce the relevant page. > > Anyone know if this is the correct way to do this sort of thing, or how to > get it to work...? > > Cheers, > > -- > Bob Arnott > > =========================================================================== > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". > Some relevant FAQs on JSP/Servlets can be found at: > > http://archives.java.sun.com/jsp-interest.html > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.jsp > http://www.jguru.com/faq/index.jsp > http://www.jspinsider.com > =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://archives.java.sun.com/jsp-interest.html http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.jsp http://www.jguru.com/faq/index.jsp http://www.jspinsider.com