posted 18 years ago
i have two dropdown box in a page.one dropdown bow is headed as category and another dropdown box headed as subcategory.below the category i have an add button.and below the subcategory i have an another add buton.
the code which i have written is that
if(request.getParameter("N1").equalsIgnoreCase("ADD"))
{
str0=request.getParameter("N1");
System.out.println("the value of str0 is"+str0);
str1=request.getParameter("D1");
System.out.println("the value of str1 is"+str1);
}
if(request.getParameter("D1").equalsIgnoreCase("AllenSolly"))
{
try
{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/operations","","");
stmt=conn.createStatement();
rs=stmt.executeQuery("select * from category where categoryname='"+str00+"'");
if(rs.next())
{
catid=rs.getInt(2);
CATEGORYID=Integer.toString(catid);
System.out.println("THE CATEGORYID IS"+CATEGORYID);
session.setAttribute("ALLENSOLLY",CATEGORYID);
System.out.println(" NOW THE CATEGORYID IS"+CATEGORYID);
//application.setAttribute("ALLENSOLLY",CATEGORYID);
//pageContext.setAttribute("ALLENSOLLY", CATEGORYID, PageContext.APPLICATION_SCOPE);
session.setAttribute("INFORMATION",information0);
System.out.println(" NOW you are here");
}
}catch(Exception e)
{
System.out.println("THE EXCEPTION IS"+e);
}
}
this is for category
and for similarly for subcategory i have written code
if(request.getParameter("E2").equalsIgnoreCase("pleaseadd"))
{
st00=request.getParameter("E2");
System.out.println("the value of st00 is"+st00);
}
if(request.getParameter("E1").equalsIgnoreCase("men"))
{
try
{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/operations","","");
stmt=conn.createStatement();
rs=stmt.executeQuery("select * from subcategory where subcategoryname='"+str001+"'");
if(rs.next())
{
parent_id=rs.getInt(2);
PARENT_ID=Integer.toString(parent_id);
System.out.println("The PARENT_ID is"+PARENT_ID);
childid=rs.getInt(3);
CHILD_ID=Integer.toString(childid);
System.out.println("The CHILDID is"+CHILD_ID);
session.setAttribute("PARENT",PARENT_ID);
session.setAttribute("MEN",CHILD_ID);
session.setAttribute("INFORMATION1",information1);
}
}catch(Exception e)
{
System.out.println("THE EXCEPTION IS"+e);
}
}
System.out.println("i m complete>>>>");
%>
but the problem is that whenever i m clicking the add button of category i m getting null pointer excption.
but if i remove the code of 2nd dropdown box it is running correctly.
plz help me in this regard.