deleting messages using checkbox in JSP

deleting messages using checkbox in JSP

Am working on a Mail Server Project. In that I have Inbox And Outbox Messages. Now Each and Every message is deleting correctly in my project. But Problem occurs when i use to delete the last message left in both in/out box. i have done the validations which says an alert while i directly click on button(which it should show) without checking it but if during last message left in mail and its already checked;i click on button it shows an error. A when there is no message in it and i click on delete its showing jasper error(Instead of showing 'there is no message in outbox/inbox'). am posting my code also.....

<html>
<head>
<script>
    function ValidateForm()
    {
        var flag = false;
        for(i=0;i< document.frm.inboxchk.length;i++)
        {
            if(document.frm.inboxchk[i].checked)
                flag = true;
        }

        if(!flag)
        {
            alert('Please select Mails');
            return false;
        }
        return true;
    }
</script>
</head>
<body>
<form action="DeleteOutbox.jsp" method="post" name="frm" onsubmit="return ValidateForm();">

outbox.jsp

<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.io.File"%>
<%@ page import="java.util.*"%>
<%

    PMS.common.PMSDBManager obj = new PMS.common.PMSDBManager();
    String sesUserId=(String)session.getAttribute("UserId");
    if(sesUserId == null)
    {   
        response.sendRedirect("Login.jsp");
    }
    else
    {   
        String empid=request.getParameter("empid");
        if(sesUserId == null)
        {   
            response.sendRedirect("Login.jsp");
        }


        Calendar cal = Calendar.getInstance();
        String CurrentTime = cal.get(Calendar.HOUR) + ":" + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND);
        String CurrentDate = cal.get(Calendar.YEAR) + "/" + (cal.get(Calendar.MONTH)+1) + "/" + cal.get(Calendar.DATE);
        String sql="SELECT * FROM mstOutbox WHERE fromuid='"+sesUserId+"' AND dstatus='N'";
        ResultSet rs=obj.getResultSet(sql); 

%>  <center><i><h4>OUTBOX:</h4></i>
    <table BORDER="1" CELLPADDING="2">
    <tr>    <td></td>
        <td>Subject</td>
        <td>To</td>
        <td>Date</td>
        <td>Time</td>
    <tr>
<% 

    while(rs.next())
    { 
        int frmid=rs.getInt("touid");
        String sql1="SELECT * FROM mstRegistration WHERE userid='"+frmid+"'";
        ResultSet rs1=obj.getResultSet(sql1);
        while(rs1.next())
        {
        %>
    <tr>    <td><input type="checkbox" name="inboxchk" value="<%=rs.getInt("omailid")%>"></td>
        <td><h4><i><a href="Displaymail.jsp?empid=<%=rs.getInt("omailid")%>&userid=<%=rs1.getString("userid")%>&outbox=Y" target="middle_pane"><%out.println(rs.getString("subject"));%></a></i></h4></td>
        <td><h4><i><%out.println(rs1.getString("firstname"));%></i></h4></td>
        <td><h4><i><%out.println(rs.getString("date"));%></i></h4></td>
        <td><h4><i><%out.println(rs.getString("time"));%></i></h4></td>
    </tr>
<%}}
%>
    </table>
    <input type="submit" name="delete" value="Delete Mail" onClick="return ValidateForm();">
    </center>
</form>
</body>
</html>
<%}%>

deleteout.jsp

<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.io.File"%>
<%
    PMS.common.PMSDBManager obj = new PMS.common.PMSDBManager();
    String sesUserId=(String)session.getAttribute("UserId");
    if(sesUserId == null)
    {   
        response.sendRedirect("Login.jsp");
    }
    else
    {   

        String[ ] touserId = request.getParameterValues("inboxchk");
        boolean booln = false;
        for(int i=0;i<touserId.length;i++)
        {
            System.out.println("IN DELETE PAGE OF OUTBOX>>>>>>>>>>>>>>>>>>"+touserId[i]);

            String delsqlinx = "UPDATE mstOutbox SET dstatus='Y' WHERE omailid='"+touserId[i]+"' AND fromuid='"+sesUserId+"'";

            booln = obj.executeQuery(delsqlinx);
        }
        response.sendRedirect("Outbox.jsp");
}%>
View Answers









Related Tutorials/Questions & Answers:
deleting messages using checkbox in JSP
deleting messages using checkbox in JSP  Am working on a Mail Server Project. In that I have Inbox And Outbox Messages. Now Each and Every message is deleting correctly in my project. But Problem occurs when i use to delete
deleting messages using checkbox in JSP
deleting messages using checkbox in JSP  Am working on a Mail Server Project. In that I have Inbox And Outbox Messages. Now Each and Every message is deleting correctly in my project. But Problem occurs when i use to delete
Advertisements
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  how to insert check box value to the database using jsp my code is <link href...; <td align="center"> <input type="checkbox
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's... for="pack_meal"></label> <input type="checkbox
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's...;   Here is a simple jsp code that insert the selected checkbox values
JSP CheckBox
JSP CheckBox          JSP CheckBox is used to create a CheckBox in JSP..._TO_REPLACE_1 The Tutorial illustrate an elaborate example from 'JSP CheckBox
JSP Checkbox
JSP Checkbox In this tutorial you will learn how to create a checkbox using JSP. As we know, checkbox allows multiple selection at a time, but radio... selection always go for checkbox. Using the example we will try to understand how
Deleting Cookie in JSP
Deleting Cookie in JSP In this section, we will discuss about deleting cookies in JSP with an example. Cookie class : In JSP , cookie are the object... be added to an HttpResponse object using HttpResponse.addCookie(). To extract
how to get the checkbox value in jsp
how to get the checkbox value in jsp  how to get the checkbox value in jsp?   JSP CheckBox Example - how to get the checkbox value in jsp
messages to the screen without using "document.write()"
messages to the screen without using "document.write()"  To write messages to the screen without using "document.write
checkbox selection in jsp
checkbox selection in jsp  hey guys i am working on a web based project using jsp. In my project i am having 9 check boxes in 3 rows in the same form. I want to select i check box from each row and also i want to avoid many
checkbox with dropdown listbox in jsp
checkbox with dropdown listbox in jsp  i loaded the the data into the drop down listbox in jsp from access database.now i have to add a check box,if it checked means dropdownlist box carryout the data's,else it should
checkbox
checkbox  how to insert multiple values in database by using checkbox in jsp
display messages in short - JSP-Servlet
display messages in short  hi sir, i am getting a full text message and that is shown in the table after sending a email.But now i have... in javascripts or in jsp... Thanks and Regards Harini V
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
delete multiple row using checkbox
delete multiple row using checkbox  how to delete multiple row in a table which is connected to database using checkbox
Learn about JSP CheckBox
Learn JSP CheckBox The tutorial highlight the features by whihc you will be able to know what is JSP checkbox and also how it works in creating a checkbox... as from 'JSP CheckBox'. To understand and grasp the example we create
Deleting Records using the Prepared Statement
Deleting Records using the Prepared Statement       This section helps us for deleting the records from the database table by using the PreparedStatement interface
insert data in the database using checkbox
insert data in the database using checkbox  i am fetching data from the database using servlet on the jsp page and there is checkbox corresponding...;input type="checkbox" name="check<%=i%>" value=<%= rs.getString("bookid
display messages in short - JSP-Servlet
display messages in short  dear sir, I am able to send a email and also i am able to getting a message from that email ,storing that in a data base and retrieving showing that in a table .But now i want to get
display messages in short - JSP-Servlet
display messages in short  dear sir, i am sending a mail and then displaying all subject, matter and attached file in the table .But in table i have to get a short message i.e starting few words then dots like that ,when a mouse
display messages in short - JSP-Servlet
display messages in short  dear sir, i am sending a mail and then dialaing all subject, matter and attached file in the table .But in table i have to ge a short message i.e starting few words then dots ,when a mouse
delete multiple row using checkbox
delete multiple row using checkbox  delete multiple row using checkbox   We are providing you the code where we have specified only three... i=0; while(rs.next()){ %> <tr><td><input type="checkbox" name
Adding checkbox in table using that delete table rows
Adding checkbox in table using that delete table rows  I need coding for how to add checkbox in table,the table data from database.Using that checkbox select more than than one rows,and using delete button i want to delete
insert checkbox in cell using POI api in java
insert checkbox in cell using POI api in java  I need to insert checkbox in excel cell using POI and java. Any one help me on this. Ashok S
https security alert messages - JSP-Servlet
with https link. After logging into that application using that https link, I will be redirected to a jsp page. I have one more https link inside a jsp...//MyJsp1(myhomepage) In My JSP...I've another https link pointing to below link
JSP Delete Record From Table Using MySQL
JSP Delete Record From Table Using MySQL This tutorial explains you that how to write a JSP for deleting a record from database table. In this section you... will give an example for deleting a record of a database table in jsp. To accomplish
Checkbox Problem--Please Check this - JSP-Servlet
Checkbox Problem  I am facing a problem while creating a check box in JavaScript. Can any one share the part of code to create a checkbox in JavaScript
Display JSP selected listbox and checkbox in xml-please help me
Display JSP selected listbox and checkbox in xml-please help me  Hi, I have three Listbox on my jsp page. I want to do following:ADS_TO_REPLACE_1... jsp. When user select something from 2nd list, third page contains checkbox
deleting file
deleting file   how to delete a file from a folder and its corresponding path in database using a servlet
Deleting a Row from SQL Table Using EJB
Deleting a Row from SQL Table Using EJB       In the given example of Enterprise Java Bean, we are going... that describes how to delete a particular row from the database table using EJB. The steps
Is JSF using JSP?
Is JSF using JSP?  Is JSF using JSP
java code using combobox,radiobutton,checkbox
java code using combobox,radiobutton,checkbox  hi, send me java code for entering student details into ms access database, the code should includes combo box,radiobutton and checkboxes pl send as early as possible
tree using jsp code
tree using jsp code  i want to draw a tree structure of a family hierarchy using jsp code
report generation using jsp
report generation using jsp  report generation coding using jsp
A Java Program by using JSP
A Java Program by using JSP  how to draw lines by using JSP plz show me the solution by using program
Project on mailing system using Java/JSP
Project on mailing system using Java/JSP  I am making a project on mailing system in Java/JSP. How could I display the inbox messages on the home page of user? Please tell me about how to handle these messages in database
generate charts using JSP
generate charts using JSP  any one know coding for generate bar chart or pie chart using JSP
ScatterPlot using jsp
ScatterPlot using jsp  hi, can anybody provide me code for ScatterPlot using jsp. thanks
datasource in jsp using struts
datasource in jsp using struts  how to get the datasource object in jsp.datasource is configured in struts-config.xml
BMI by using JSP Languange
BMI by using JSP Languange  Using JSP language, create a system that calculates Body Mass Index (BMI) of users who entered their weight and height. Then, system will display all the records. Can you provide me the coding
BMI by using JSP Languange
BMI by using JSP Languange  Using JSP language, create a system that calculates Body Mass Index (BMI) of users who entered their weight and height. Then, system will display all the records. Can you provide me the coding
video uploading using jsp
video uploading using jsp  how to upload a videos in web page using jsp   Hi, You can upload your video with the help of JSP file upload code. Once file is upload you can play using any video player. Get the code
Using Scriplet in JSP - JSP-Servlet
on } IN HOME JSP ****** home.jsp **** Currently I am directly using...Using Scriplet in JSP  Hi, I need to display suitable fields in my jsp but this should be done upon suitable condition becomes true for eg
using jsp's....and ajax - Ajax
using jsp's....and ajax  Hi, i need code using ajax .....in a text box when i enter an alphabet i should get list of words starts with the alphabet given in the text box
generate pdf using jsp
generate pdf using jsp  how do i generate a pdf using jsp that should query the data from the database and write it into a pdf and download the same
jsp using netbeans
jsp using netbeans  Code to access and manage multiple e-mail accounts on the same page.. user should be able to edit mail accounts' link as required
barcode reader using jsp
barcode reader using jsp  HI ALL, I need jsp code for barcode reader.When we scan the barcode image that barcode value will be stored in one textbox automatically. please helpe me. Regards Bhanu
Tiemsheet using jsp
Tiemsheet using jsp  Hi, I am working on creating timesheet using JSP. Can you please help me on how to create a timesheet in excel using jsp and users should fill the excel sheet and then on submitting it should uplaod excel
Jsp using mvc - JSP-Servlet
Jsp using mvc  hi I have written using mvc2 architecture, i have written logic in java ,i want to print a message on the form stating the the values are inserted successfully.So can you tell me how i have to write the code

Ads