Results 1 to 5 of 5
  1. #1
    mary is offline Member
    Join Date
    Jul 2007
    Posts
    51
    Rep Power
    0

    Default Exception Report:annot allocate servlet instance for path

    I have written a html page to invoke a servlet named logtest1

    and i have created that logtest1.java file in the following path.
    c:/apache tomcat/webapps/root/web-inf/classes/logtest1.java

    in the html file, i gave the path as
    Java Code:
    <form name=log method=post action= "/servlet/logtest1">
    But, when I click on submit button, I get one servlet exception as
    Java Code:
    A Servlet Exception Has Occurred
    Exception Report:
    javax.servlet.ServletException: Cannot allocate servlet instance for path 
    /servlet/logtest1
    java.lang.IllegalAccessException: logtest1"
    why?

  2. #2
    Heather is offline Senior Member
    Join Date
    Jun 2007
    Posts
    164
    Rep Power
    8

    Default

    can you paste more code?

  3. #3
    mary is offline Member
    Join Date
    Jul 2007
    Posts
    51
    Rep Power
    0

    Default

    The HTML code as follows:
    Java Code:
    <html>
    <head>
    <title>Login Screen</title>
    </head>
    <body bgcolor="pink">
    <h1 align=center>Login Screen</h1>
    <hr size=2 width=100&#37;>
    <br><br><br><br><br><br><br><br><br>
    <form name="log" method="post" action="/servlet/logtest1">
    <table borer=1 align=center>
    <tr>
    <td>Userid:</td>
    <td><input type=text name=userid ></td>
    </tr>
    <tr>
    <td>Password:</td>
    <td><input type=password name=psw></td>
    </tr>
    <tr><td><input type=submit name='login'width=05 value='Login'></td></tr>
    </table>
    </body>
    </html>
    The servlet code as follows:
    Java Code:
    import java.lang.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.http.HttpSession;
    import java.util.*;
    import java.util.Properties;
    import java.io.*;
    import java.text.*;
    
    
    class logtest1 extends HttpServlet
    {
    PrintWriter out=null;
    
    public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
    {
    response.setContentType("text/html");
    out = response.getWriter();
    String fileName = new String();
    String aDataString = new String();
    String user=request.getParameter("userid");
    fileName = "MyFileName.dat";
    //aDataString = "I want to write this string to a file.";
    FileWriter fw = new FileWriter(fileName);
    BufferedWriter bw = new BufferedWriter(fw);
    PrintWriter outFile = new PrintWriter(bw);
    outFile.println(aDataString);
    System.out.println("File has been created successfully");
    outFile.close();
    }
    //System.out.println("out of dopost method");
    }

  4. #4
    sunnyvijaya is offline Member
    Join Date
    Aug 2007
    Posts
    2
    Rep Power
    0

    Default

    give the path in web.xml of the
    <servlet>
    <servlet-name>logtest1 </servlet-name>
    <serlvet-class>logtest1 <serlvet-class>
    </servlet>

    and <servletmapping> also

  5. #5
    goodguy052 is offline Member
    Join Date
    Nov 2007
    Posts
    2
    Rep Power
    0

    Default

    First of all, in the path you have shown c:/apache tomcat/webapps/root/web-inf/classes/logtest1.java the file name should be logtest1.class, not logtest1.java

Similar Threads

  1. Replies: 1
    Last Post: 03-08-2008, 06:41 PM
  2. New Instance for SWT
    By srinivasa_v in forum SWT / JFace
    Replies: 1
    Last Post: 08-08-2007, 01:02 AM
  3. Replies: 1
    Last Post: 08-07-2007, 03:47 PM
  4. A Servlet Exception Has Occurred
    By gabriel in forum JDBC
    Replies: 1
    Last Post: 08-07-2007, 02:28 AM
  5. Instance variable
    By Jack in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 04:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •