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
Add a ment  | 

1 Answer 1

Reset to default 1

You 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