Can't create basic Servlet in 12

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

Steps....

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?

Sigh....

0
5 comments

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

0

http://youtrack.jetbrains.com/issue/IDEA-97589

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

0
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

My Template (for Web:Java code templates:Servlet Class.java) 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.

Thanks,

-m

---------------------------

#parse("File Header.java")
#if (${PACKAGE_NAME} != "")
package ${PACKAGE_NAME};
#end
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, java.io.IOException
       {
       
        response.setContentType("text/html");
         PrintWriter out = response.getWriter();
         
         out
                 .println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
         out.println("<HTML>");
         out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
         out.println("  <BODY>");
         out.print("    This is ");
         out.print(this.getClass());
         out.println(", using the POST method");
         out.println("  </BODY>");
         out.println("</HTML>");
         out.flush();
         out.close();

     }

-m

0

Please sign in to leave a comment.