Click here to Skip to main content
13,737,226 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
hi i am developing an application in netbeans.
in that following error occured
"package javax.servlet does not exist"

this is the code

package child;
import java.sql.*;
import java.io.*;
import javax.servlet.ServletException;//error package javax.servlet does not exist 
import javax.servlet.http.HttpServlet;//error package javax.servlet does not exist 
import javax.servlet.http.HttpServletRequest;//error package javax.servlet does not exist 
import javax.servlet.http.HttpServletResponse;//error package javax.servlet does not exist 
import javax.servlet.http.HttpSession;//error package javax.servlet does not exist 


public class addnewphonenumber extends HttpServlet {//error "cannot find symbol"
  


String na1;
int c;
    
     protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
       
       response.setContentType("text/html");
       PrintWriter pout =response.getWriter();
       if(request.getParameter("oks") != null)
      {
        try{
            String flag1="no";
              Dbload db=new Dbload();
       Connection con=db.getConnection();
       
       ResultSet rs;
            PreparedStatement ps;
            String mob= request.getParameter("mobile");
            na1=request.getParameter("str");
            
            ps= (PreparedStatement) con.prepareStatement("select * from login where username=?");
            ps.setString(1,na1);
            rs=ps.executeQuery();
            if(rs.next())
            c=rs.getInt(1);
            ps.close();
            ps=con.prepareStatement("insert into mobnumbers(id,mob,flag) values(?,?,?);");
            ps.setInt(1,c);
            ps.setString(2,mob);
            ps.setString(3, flag1);
            ps.executeUpdate();
           ps.close();
           con.close();
           response.sendRedirect("blank.jsp");
        }
        catch(SQLException e){
               response.sendRedirect("addphone.jsp");
        }
     }
        
    }
        
    }


Please help me to solve this error.
Thank you....
Posted 19-Mar-12 23:11pm
Updated 20-Mar-12 19:03pm
v3

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You need to add the "Java-EE-Glassfish-V3" library to the project.
That is done in the project's properties (right click on project).
  Permalink  
Comments
Neha Thanka 22-Mar-12 2:33am
   
I used Tomcat in this project.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web05-2016 | 2.8.180920.1 | Last Updated 21 Mar 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100