public void service(HttpServletRequest hreq,HttpServletResponse hres)
{
try
{
if(hreq.isRequestedSessionIdValid())
{
con.setAutoCommit(true);
String text=hreq.getParameter("ctext");
HttpSession hs=hreq.getSession(false);
System.out.println("entered into commadd");
String uname=(String)hs.getAttribute("uname");
String temp=(String)hs.getAttribute("uids");
int uids=Integer.parseInt(temp);
temp=(String)hreq.getParameter("tno");
int tno=Integer.parseInt(temp);
System.out.println("tno in commadd class:"+tno);
hs.removeAttribute("tno");
if(temp!=null&&text!=null&&text.trim()!=null&&text.trim().length()!=0)
{
PreparedStatement pstmt=con.prepareStatement("insert into commdbs values(cs.nextval,?,?,?,?)");
pstmt.setInt(1,tno);
pstmt.setInt(2,uids);
pstmt.setString(3,text);
pstmt.setString(4,uname);
int i;
i=pstmt.executeUpdate();
}
System.out.println("redirecting to home page");
String s=hres.encodeURL("homeurl");
hres.sendRedirect(s);
}
else
{
String sr=hres.encodeURL("invalidurl");
hres.sendRedirect(sr);
}

}
catch(Exception e)
{
System.out.println(e);
try{
String sr=hres.encodeURL("errorurl");
hres.sendRedirect(sr);
}
catch(Exception e2)
{System.out.println(e2);}

}


}