help me in compling this code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bhanu08
    New Member
    • Jan 2007
    • 19

    #1

    help me in compling this code

    hi
    iam trying to complie this code
    Code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.sql.*;
    
    public class MainServlet extends HttpServlet {
    	
    	RequestDispatcher dis = null;
    	
    	public void doPost(HttpServletRequest req,HttpServletResponse resp) {
    		
    		resp.setContentType("text/html");
    		String action = req.getParameter("submit");
    		Dispatcher dis = null;
    		try {
    			
    			if (action.equalsIgnoreCase("login")) {
    				System.out.println("login invoked");
    				loginAction(req, resp);
    			}
    			
    		}catch(Exception e){
    		}
    	}
    
    	private void loginAction(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException
    	{
    		System.out.println("Accounts Button Clicked");
    		//System.out.println("Hash table values "+ht);
    		dis= req.getRequestDispatcher("/home.html");
    		if (dis != null) {
    
    			// forward request to next page
    			dis.forward(req, resp);
    		}
    	}
    }
    Iam getting an error saying
    package javax.servlet.h ttp does not exist
    please help in compileing the code
    Iam begginer to servlets concept
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    most probably the specific library missing .....

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by bhanu08
      hi
      iam trying to complie this code
      Code:
      import javax.servlet.*;
      import javax.servlet.http.*;
      import java.util.*;
      import java.sql.*;
       
      public class MainServlet extends HttpServlet {
       
      	RequestDispatcher dis = null;
       
      	public void doPost(HttpServletRequest req,HttpServletResponse resp) {
       
      		resp.setContentType("text/html");
      		String action = req.getParameter("submit");
      		Dispatcher dis = null;
      		try {
       
      			if (action.equalsIgnoreCase("login")) {
      				System.out.println("login invoked");
      				loginAction(req, resp);
      			}
       
      		}catch(Exception e){
      		}
      	}
       
      	private void loginAction(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException
      	{
      		System.out.println("Accounts Button Clicked");
      		//System.out.println("Hash table values "+ht);
      		dis= req.getRequestDispatcher("/home.html");
      		if (dis != null) {
       
      			// forward request to next page
      			dis.forward(req, resp);
      		}
      	}
      }
      Iam getting an error saying
      package javax.servlet.h ttp does not exist
      please help in compileing the code
      Iam begginer to servlets concept
      Have you installed the j2ee compiler?

      Comment

      • bhanu08
        New Member
        • Jan 2007
        • 19

        #4
        Originally posted by r035198x
        Have you installed the j2ee compiler?
        no i installed only jdk1.5 can u please tell where can i get the J2EE n how to comple the code

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by bhanu08
          no i installed only jdk1.5 can u please tell where can i get the J2EE n how to comple the code
          You can download it from here

          Comment

          • bhanu08
            New Member
            • Jan 2007
            • 19

            #6
            Originally posted by r035198x
            You can download it from here
            thanx for ur reply
            can u please tell me after downloading what should i do

            Comment

            • r035198x
              MVP
              • Sep 2006
              • 13225

              #7
              Originally posted by bhanu08
              thanx for ur reply
              can u please tell me after downloading what should i do
              Follow the installation instructions. Make sure you also downloaded a server for deploying your applications from.

              Comment

              • bhanu08
                New Member
                • Jan 2007
                • 19

                #8
                Originally posted by r035198x
                Follow the installation instructions. Make sure you also downloaded a server for deploying your applications from.
                ya i had installed tom cat will tht be ok.

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Originally posted by bhanu08
                  ya i had installed tom cat will tht be ok.
                  Yes. Tomcat is fine.

                  Comment

                  • bhanu08
                    New Member
                    • Jan 2007
                    • 19

                    #10
                    Originally posted by r035198x
                    Yes. Tomcat is fine.
                    i installed j2ee n tomcat it still says

                    package javax.servlet does not exist


                    what to do sir ??
                    plz help me

                    Comment

                    • r035198x
                      MVP
                      • Sep 2006
                      • 13225

                      #11
                      Originally posted by bhanu08
                      i installed j2ee n tomcat it still says

                      package javax.servlet does not exist


                      what to do sir ??
                      plz help me
                      I hope you are not using javac from the SDK to compile the servlet.

                      Comment

                      • Chaitanyabbsr
                        New Member
                        • Mar 2007
                        • 1

                        #12
                        Originally posted by bhanu08
                        i installed j2ee n tomcat it still says

                        package javax.servlet does not exist


                        what to do sir ??
                        plz help me
                        Before compile put the servlet.jar in your class path.

                        Comment

                        • bhanu08
                          New Member
                          • Jan 2007
                          • 19

                          #13
                          Originally posted by r035198x
                          I hope you are not using javac from the SDK to compile the servlet.
                          in the command prompt iam going to the path

                          C:\Sun\AppServe r\jdk\bin>

                          where my java is installed

                          and giving command as

                          javac MainServlet.jav a

                          package javax.servlet does not exist error is coming

                          i had installed J2ee i want know the use of it

                          Comment

                          • bhanu08
                            New Member
                            • Jan 2007
                            • 19

                            #14
                            Originally posted by Chaitanyabbsr
                            Before compile put the servlet.jar in your class path.
                            in the command prompt iam going to the path

                            C:\Sun\AppServe r\jdk\bin>

                            where my java is installed

                            and giving command as

                            javac MainServlet.jav a

                            package javax.servlet does not exist error is coming

                            i had installed J2ee i want know the use of it

                            wherer can i find servlet.jar file and
                            how shud i have to put servlet.jar the class path ??

                            Comment

                            • r035198x
                              MVP
                              • Sep 2006
                              • 13225

                              #15
                              Originally posted by bhanu08
                              in the command prompt iam going to the path

                              C:\Sun\AppServe r\jdk\bin>

                              where my java is installed

                              and giving command as

                              javac MainServlet.jav a

                              package javax.servlet does not exist error is coming

                              i had installed J2ee i want know the use of it

                              wherer can i find servlet.jar file and
                              how shud i have to put servlet.jar the class path ??
                              here is an article on how to set the class path.

                              Comment

                              Working...