Skip to content

Instantly share code, notes, and snippets.

@eirikbakke
eirikbakke / gist:1056064
Created June 30, 2011 11:40
Basic structure of an HTML file.
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<!-- Include a stylesheet called stylesheet.css . -->
<link href="stylesheet.css" rel="stylesheet" title="Normal" />
<title>The title of the page.</title>
</head>
<body>
<!-- The page's content goes here. -->
@eirikbakke
eirikbakke / gist:1056066
Created June 30, 2011 11:42
Basic structure of a Servlet.
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/* The relative URL that this servlet will be handling. For instance, if we are running
Tomcat locally with an Eclipse project called "SomeProject", then by specifying "/Main"
@eirikbakke
eirikbakke / gist:1056079
Created June 30, 2011 11:50
Basic structure of a JSP file that generates a HTML file.
<!-- Boilerplate. -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:c="http://java.sun.com/jsp/jstl/core"
version="2.0">
<jsp:directive.page
language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" />
<jsp:text><![CDATA[<!doctype html>]]></jsp:text>
<html>
<head>
@eirikbakke
eirikbakke / gist:1059266
Created July 1, 2011 19:49
Example CSS file
/* Applies to the entire body of the HTML document (except where overridden by more specific
selectors). */
body {
margin: 25px;
background-color: rgb(240,240,240);
font-family: arial, sans-serif;
font-size: 14px;
}
/* Applies to all <h1>...</h1> elements. */
@eirikbakke
eirikbakke / gist:1059502
Created July 1, 2011 22:05
Example of an HTML form
<!-- To submit form data back to the same page (and thus the same Servlet), use "#" for the
action. Otherwise specify a relative URL to a different page for the action. -->
<form action="#">
<label for="ageField" >Your age: </label>
<input type="text" name="ageParam" id="ageField" /><br/>
<label for="colorField">Favorite color:</label>
<input type="text" name="colorParam" id="colorField"/><br/>
<input type="submit" value="Click me to submit!"/>
</form>
@eirikbakke
eirikbakke / gist:1059621
Created July 2, 2011 00:18
Generating an empty iframe tag from JSP
<!-- Not like this: -->
<iframe width="560" height="349" src="http://www.youtube.com/embed/FaMTedT6P0I" />
<!-- Nor like this (JSP will just convert it to use a self-closing tag as above): -->
<iframe width="560" height="349" src="http://www.youtube.com/embed/FaMTedT6P0I"></iframe>
<!-- But like this (tell JSP to output the elements exactly like we wrote them): -->
<![CDATA[
<iframe width="560" height="349" src="http://www.youtube.com/embed/FaMTedT6P0I"></iframe>
]]>
@eirikbakke
eirikbakke / gist:1066999
Created July 6, 2011 10:53
Boilerplate for the DBManager class.
package org.meetproj.model;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
@eirikbakke
eirikbakke / gist:1069036
Created July 7, 2011 07:19
The VideoDatabase Class
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
public class VideoDatabase {
public static List<Video> loadVideos() throws SQLException {
throw new UnsupportedOperationException("TODO: Implement when instructed.");
}
public static void insertVideo(Video v) throws SQLException {
@eirikbakke
eirikbakke / gist:1074542
Created July 10, 2011 13:40
The DatabaseConnector class.
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public final class DatabaseConnector {
private static DatabaseConnector instance;
private static String useMySQL = null;
// Deployment note: Replace with a real server name.
--- a 2013-02-19 20:50:11.000000000 -0500
+++ b 2013-02-19 20:50:04.000000000 -0500
@@ -1 +1 @@
-Angela teaches a FOB the pinky-swear.
+Samples teaches a FOB the pinky-swear.