显示两个servlet之间的确认

时间:2015-12-31 09:12:17

标签: java servlets

我有一个名为Delete_product_Kind_A的servlet。

当用户删除A类产品时,将调用servlet并在数据库中查找A类产品。

应显示确认删除产品的用户。如果用户选择“是”,它将在另一个servlet Action_Delete上发出请求。

那么,请告诉我,如何在两个serlvet之间显示确认?

我在互联网上找到了这样的代码:

out.println("<script>");
out.println("confirm('somethings')");
out.println("</script>");

但我不知道如何获得它的价值来检查是或否。 非常感谢。

2 个答案:

答案 0 :(得分:-1)

只需使用if语句并对第二个servlet执行fire和ajax调用:

if(confirm('something?')) {
    alert('YES clicked!');
    // perform here the ajax call to Action_delete servlet
} else {
    alert('Cancel clicked!');
} 

答案 1 :(得分:-1)

最好的方法是使用控制器类或使用控制器设计模式

[controller design pattern][1]

因为您需要在删除之前进行身份验证并使用2个servlet