Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java code templates [Eclipse]

 
asirob civokviz
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am pretty new to Eclipse and I'm trying to find plugin or a feature
of that IDE that can automatically generate templates for java classes.
For example when I create new servlet it would be nice if Eclipse
create common code for all servlets:

public class ServletName extends HttpServlet{

doPost(request,response){}

doGet(...){}

...

}

Anyone knows how to find this plugin or configure Eclipse to do this???

Thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34396
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Asirob,
I can think of ways to do it in two steps.

Approach 1:
a) New class --> extends HttpServlet
b) Overwrite/implements methods --> pick those two

Approach 2:
a) New class --> extends HttpServlet
b) Create a template called "servlet" to expand to the two methods. Templates are defined in the Eclipse preferences under the java section.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic