admin管理员组文章数量:1336402
What I have tried is
First.jsp
<form name = "button" style="VISIBILITY: visible">
<table cellspacing=5 cellpadding=5 bgcolor="lightblue" colspan=2 rowspan=2 align="center">
<TR> <TD> <INPUT TYPE="button" onclick="sub1();hide();" VALUE="DOWNLOAD"></TD>
<script>
function popup()
{
popupWindow = window.open('delete','name','width=300,height=100');
popupWindow.focus();
window.close();
}
delete.jsp
<%
String Pdfpath= session.getAttribute("pdfpath").toString();
File f =new File(Pdfpath);
Boolean flag=false;
if(f.exists())
{
flag=f.delete();
}
else
{
out.println("File not found to delete");
}
%>
<html>
<head>
<title>Delete file in java</title>
</head>
<body>
<%
if(flag==true)
{
out.println("File Has Bean deleted successfully");
}
else
{
out.println("Error: Unable To Delete The File");
}
%>
</body>
</html>
From my first jsp I'm passing some path to another delete.jsp on the button click.That jsp delete the file on my directory and giving an message.I want that message to es of in a message box at the same time that window should not e.
I don't like add all deletion code in javascript function so that I'm going for another jsp. Is it possible to hide the window and show only the confirm message box in delete.jsp page.I need some help.
Thanks
What I have tried is
First.jsp
<form name = "button" style="VISIBILITY: visible">
<table cellspacing=5 cellpadding=5 bgcolor="lightblue" colspan=2 rowspan=2 align="center">
<TR> <TD> <INPUT TYPE="button" onclick="sub1();hide();" VALUE="DOWNLOAD"></TD>
<script>
function popup()
{
popupWindow = window.open('delete','name','width=300,height=100');
popupWindow.focus();
window.close();
}
delete.jsp
<%
String Pdfpath= session.getAttribute("pdfpath").toString();
File f =new File(Pdfpath);
Boolean flag=false;
if(f.exists())
{
flag=f.delete();
}
else
{
out.println("File not found to delete");
}
%>
<html>
<head>
<title>Delete file in java</title>
</head>
<body>
<%
if(flag==true)
{
out.println("File Has Bean deleted successfully");
}
else
{
out.println("Error: Unable To Delete The File");
}
%>
</body>
</html>
From my first jsp I'm passing some path to another delete.jsp on the button click.That jsp delete the file on my directory and giving an message.I want that message to es of in a message box at the same time that window should not e.
I don't like add all deletion code in javascript function so that I'm going for another jsp. Is it possible to hide the window and show only the confirm message box in delete.jsp page.I need some help.
Thanks
Share edited Apr 4, 2013 at 10:45 Vignesh Vino asked Apr 4, 2013 at 9:16 Vignesh VinoVignesh Vino 1,2384 gold badges26 silver badges51 bronze badges 1- Use JSTL and EL as much as you can :) – kayz1 Commented Apr 4, 2013 at 12:48
1 Answer
Reset to default 1You can use the following code as delete.jsp ;)
<%
String Pdfpath = session.getAttribute("pdfpath").toString();
File f = new File(Pdfpath);
Boolean flag = false;
if (f.exists()) {
flag = f.delete();
} else {
out.println("File not found to delete");
}
%>
<html>
<head>
<title>Delete file in java</title>
</head>
<body>
<%
String message = "";
if (flag == true) {
message = "File Has Bean deleted successfully";
} else {
message = "Error: Unable To Delete The File";
}
%>
<script type="text/javascript">
alert('<%=message%>');
</script>
</body>
</html>
本文标签: javaHow to add Message box instead of new window in jspStack Overflow
版权声明:本文标题:java - How to add Message box instead of new window in jsp - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742403462a2468347.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论