0

I know there have been similar questions asked but I just started learning this in school and after following the professor's step-by-step explanation I always get an error.

I'm using Apache NetBeans 12.3 and I followed this video that was provided to us in class:

https://www.youtube.com/watch?v=zH6YYQ82V58&t=6s

My index.html looks like this:

<html>
    <head>
        <title>First Servlet Example</title>
         <meta charset="UTF-8">
         <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
    
        <a href="FirstServlet">Click here..</a> 
    
    </body>
</html>

And the Servlet looks like this:

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class FirstServlet extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
            out.println("<!DOCTYPE html>");
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet FirstServlet</title>");            
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>Servlet FirstServlet at " + request.getContextPath() + "</h1>");
            out.println("</body>");
            out.println("</html>");
        }
    }


    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}

Most of it is code that came up automatically, all I was supposed to change was the title and the link. But when I press "Click here..." to go to the servlet I get this error:

enter image description here

My professor is not answering any emails and I feel very stuck as I don't have much experience with programming.

  • Related: [How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version](https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi). This means there is Java code which has been compiled using one version of Java, but which you are trying to run using a different (incompatible) version of Java. – andrewJames May 28 '21 at 14:03
  • General note: Please [do not provide screenshots](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question) of error messages. Instead, please [edit] your question and copy/paste the text of the complete error message into the question. – andrewJames May 28 '21 at 14:05

0 Answers0