Can't create basic Servlet in 12

Trying to create just a basic Servlet is extremly frustrating in IDEA 12 (same as 11?)


0. No IDEA 12 step by step documentation found, so....

1. I create a web project.

1.5. Added Tomcat App Server.

2. I create a package under src

3. I create a Servlet

Then notice that idea leaves a "{Package Name}" element in the servlet (that of course won't compile) even though there is a package statement. IDEA doesn't put a semi-colon after the package name at top. OK, fixed those.

4. Clicked in the web.xml and tried to enter the deployment descriptor elements. There's a "+" enabled, but clicking it ... NOTHING HAPPENS. Same for Servlet Mapping. Clicked and highligted everything I could possibly think of in web.xml and other parts of the "Web" view. Here again, the IDE is utterly confusing. There is an ENABLED "+" button for adding the Servlet mapping, but clicking it....NOTHING HAPPENS. Again.


I also noticed that after entering some text in the servlet description, I was not able to edit it! Not sure what this feature is all about...


Even after manually adding the servlet path information, I can't just "run" the web application and have the Servlet work. Sure, the HTML page (index.jsp) works OK, but the Servlet doesn't even look like it's deployed (possibly related to all the other problems above?) No idea.

Looking at the directories IDEA creates under the project (test, web, etc.), there's not a single directory with everything in it needed to work.

Why is this so difficult and so much apparent burdent put on the developer to "know" just exactly how "IDEA works"?

For what is relatively simple in other IDEs, it often seems more difficult to use IDEA than using advanced features of Java. I would prefer on banging my head on my app logic, not on the IDE. Yet, that's what I seem to often do with IDEA.

Am I honestly alone on this?



It works for me. Could you submit a bug report for further investigation?


{Package Name} error is unrelated and is caused by your custom file template.


Here again, I'm confused.

Thanks for your reply, but could you be more specific?

I've never created a "Custom File Template".

Looking in the File Templates, they're all the defaults to the best of my knowledge.

Also, I didn't see a Template for a Servlet.

Can you suggest where this setting might be?

Thanks much in advance.

- m


My Template (for Web:Java code templates:Servlet is below.

I've never customized this so I don't see how it's different from the default (or why it's putting in artifacts or not creating a semicolon after the package name.




#if (${PACKAGE_NAME} != "")
package ${PACKAGE_NAME};
public class ${Class_Name} extends javax.servlet.http.HttpServlet {
     protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
       throws javax.servlet.ServletException,
         PrintWriter out = response.getWriter();
                 .println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
         out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
         out.println("  <BODY>");
         out.print("    This is ");
         out.println(", using the POST method");
         out.println("  </BODY>");




Please sign in to leave a comment.