package miniforum.action; 
 
import miniforum.data.MessageUtils; 
import miniforum.IConstants; 
 
import javax.servlet.*; 
import javax.servlet.http.*; 
import java.io.IOException; 
 
public class DeleteServlet extends HttpServlet { 
    protected void doGet(HttpServletRequest aRequest, 
            HttpServletResponse aResponse) 
            throws ServletException, IOException { 
        HttpSession session = aRequest.getSession(); 
        String idParameter = aRequest.getParameter( 
            IConstants.ID_PARAM); 
        try { 
            int id = Integer.parseInt(idParameter); 
            ServletContext application = 
                session.getServletContext(); 
            MessageUtils.deleteForumMessage(id, application); 
        } catch (Exception ex) { 
            session.setAttribute(IConstants.LAST_ERROR, 
                "Не мога да изтрия съобщението!"); 
        } 
        aResponse.sendRedirect(IConstants.MAIN_FORM); 
    } 
}
Back to Internet Programming with Java books's web site