Simple Servlet example without eclipse

Simple servlet example – how to create servlet without eclipse

These days we are all surrounded by heavy frameworks that make life easier for us. Like maven, spring and hibernate and more. But how can we create a simple servlet website without the need of all those.

The main idea of servlet lies around very simple and intuitive files and structures. Knowing those only is good enough to built a good web app and that is what I will be showing here.

The main parts of the java web app are the following.

1. The Servlet – the java class that is handling the POST and GET http verbs
2. the deployment descriptor – web.xml. File telling how the webapp should be interacted like the url pattern
3. Servlet jar file – This is the jar handling the magic of interaction with the web for the servlet.

Structure of the webapp

apache error

Java Tomcat error: can not access a member of class with modifiers

Class org.apache.catalina.core.DefaultInstanceManager can not access a member of class with modifiers “” sun.reflect.Reflection.ensureMemberAccess(

If you are on tomcat/or anyother webserver for J2EE and getting this error, then the most probable servlet you have would look like this

package package;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

class MyServletClass extends HttpServlet {

The fix:

You have missed the class modifier public

public class MyServletClass

Should solve the problem