Home Answers Viewqa JSP-Servlet deleting messages using checkbox in JSP

 
 


shubham
deleting messages using checkbox in JSP
0 Answer(s)      a year and 3 months ago
Posted in : JSP-Servlet

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 Pages:
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
checkbox
checkbox  how to insert multiple values in database by using checkbox in jsp
JSP CheckBox
JSP CheckBox          JSP CheckBox is used to create a CheckBox in JSP... illustrate an elaborate example from 'JSP CheckBox'. To understand and grasp
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
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
deleting file
deleting file   how to delete a file from a folder and its corresponding path in database using a servlet
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
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
Help to maintain state of checkbox
is not maintained.If it is maintained then it should show checked. I am using jsp... the state of checkboxes across pages. What happens is when i check one checkbox and then go to say 2nd page then check one checkbox there and when i return
How to check a checkbox - Struts
setting the checked attribute of a checkbox to true/checked when using the tags...How to check a checkbox  Hello Community, How can i check a checkbox... please help me with the syntax??  Hi friend, my checkbox
Maintain checked checkbox status
Maintain checked checkbox status  Hi everyone In my JSP application, i have database table stored in mysql. when i display there recors using... using "Href link" , it should maintain previously selected checkboxes . So, my
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... for deleting a record of a database table in jsp. To accomplish this task we
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
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
UIButton checkbox
UIButton checkbox  iPhone UIButton checkbox example required.. can any one please explain me.. how to create a checkbox button using UIButton in XIB
Deleting messages example
Deleting messages example     ...* Flags.Flag.SEEN* Flags.Flag.USERTo delete messages, you set the message's DELETED... processing all messages, close the folder, passing in a true value to expunge
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
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
Checkbox Tag (Form Tag) Example
/checkboxTag.jsp</result> </action> Create a jsp using the tag <s...Checkbox Tag (Form Tag) Example       In this section, we are going to describe the checkbox tag. The checkbox tag
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
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: ByDefault first... from 1st list box second will fill accordingly by database using jsp. When user
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
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
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
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
Checkbox blocked - WebSevices
Checkbox blocked  Hi, i design online ticket reservation for bus. It contains no of seats. if i choose 3 or 4 seats checkbox,it will stored in my database. After i refreshing the page that checkbox seats are blocked
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
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
JavaScript Checkbox getElementById
() for checkbox in JavaScript. In the given example we are going to show an image on clicking the checkbox. This is done by using the JavaScript method getElementById... JavaScript Checkbox getElementById
Problem to display checkbox item
Problem to display checkbox item  Hi, Following is my code: <...;td> <input type="checkbox" name="check" value=<..."); while(rs.next()){ %> <tr><td><input type="checkbox" name="check
Dojo Tree With Checkbox - Framework
Dojo Tree With Checkbox  Hi Friends, I have to generate a tree structure in a jsp along with checkbox besides each node. The tree structure... with tree structure. The checkbox will have 3 states: (1) partially checked, (2
JSP - Checkbox remain checked although checked values should depend on values stored in a stateful session bean
JSP - Checkbox remain checked although checked values should depend on values.... There are 3 JSP pages, shop1.jsp , shop2.jsp and shop3.jsp where each of these pages... displays all of the items selected. The selection of items is made using checkboxes
How to change the checkbox value dynamically.
How to change the checkbox value dynamically.  Hi, I am using struts 1.2 checkbox tag. Requirement is on page load the value must be "true... the page. Then the checkbox is checked instead it have to show unchecked. And even
Problem with DOJO tree with checkbox - Framework
to generate a tree structure in a jsp along with checkbox besides each node. The tree... opens with tree structure. The checkbox will have 3 states: (1) partially... is as follows.The dialog box with tree structure (with checkbox) is done
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
Struts2.2.1 checkbox tag example.
Struts2.2.1 checkbox tag example. In this example, you will see the use of checkbox tag of struts2.2.1 framework. The checkbox tag is a UI tag that is used to render an HTML input element of type checkbox, populated by the specified
How to iterate over a checkbox group
How to iterate over a checkbox group  Hi. I am new to using JQuery... checkbox groups. Each of these groups consist of multiple checkboxes. The first... is to have a user check, say, "A" in MASTER and this causes the "A" checkbox
how to update checkbox list in database
how to update checkbox list in database  Issues: i am using... to update one by one but it's not updating by using below code .it's not adding... in the database below logic is working fine by using insert command
store value in checkbox from gridview
store value in checkbox from gridview  Please check the error...) { alert("check the messages to delete & u had limited msg...;/td> <td><input type="checkbox
coding for deleting file
coding for deleting file  coding for deleting file
jQuery to Select Multiple CheckBox
jQuery to Select Multiple CheckBox   ... program that retrieves the value of selected checkbox from server and displays... script . You can easily replace PHP with JSP, or ASP program. Steps to develop

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.