Skip to content

Instantly share code, notes, and snippets.

@lalthomas
Created November 25, 2012 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lalthomas/4142631 to your computer and use it in GitHub Desktop.
Save lalthomas/4142631 to your computer and use it in GitHub Desktop.
context text editor java autotext template
[for | for block]
for (int i=0; i<|; i++) {}
[prog | Java Program Template]
public class |MyProg {
/** Code documentation here */
public static void main(String[] args) {
/* multi-line and semi-line comments here */
// one-line comments here
System.out.println("Hello, world");
}
}
[servlet | Java Servlet Skeleton]
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class |MyServlet extends HttpServlet {
PrintWriter out;
public void doGet(HttpServletRequest req, HttpServletResponse res) {
try {
res.setContentType("text/html");
out = res.getWriter();
String html = "<html>Hello, world</html>";
out.println(html);
}
catch (Exception e) { e.printStackTrace(); }
}
public void doPost(HttpServletRequest req, HttpServletResponse res) {
try {
res.setContentType("text/html");
out = res.getWriter();
String html = "<html>Hello, world</html>";
out.println(html);
}
catch (Exception e) { e.printStackTrace(); }
}
}
[try | try-catch block]
try {
|
}
catch (Exception e) {
System.out.println("Unexpected exception");
e.printStackTrace();
}
finally {}
[while | while block]
int i=0;
while (i < |) {
i++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment