Skip to content

Instantly share code, notes, and snippets.

View darbyluv2code's full-sized avatar

Chad Darby darbyluv2code

View GitHub Profile
@darbyluv2code
darbyluv2code / spring-mvc-demo-servlet.xml
Created January 23, 2017 17:00
Spring MVC Demo - Read country options from properties file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
@darbyluv2code
darbyluv2code / todo-demo.jsp
Created April 4, 2017 17:32
Fix for JSP session tracking demo
<%@page import="java.util.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Session example</title>
</head>
@darbyluv2code
darbyluv2code / WEB-INF lib files
Created June 8, 2017 05:17
WEB-INF lib files
antlr-2.7.7.jar
c3p0-0.9.2.1.jar
cdi-api-1.1.jar
classmate-1.3.0.jar
commons-logging-1.2.jar
dom4j-1.6.1.jar
el-api-2.2.jar
geronimo-jta_1.1_spec-1.1.1.jar
hibernate-c3p0-5.2.2.Final.jar
hibernate-commons-annotations-5.0.1.Final.jar
@darbyluv2code
darbyluv2code / spring-mvc-servlet.xml
Created June 11, 2017 03:48
spring-mvc-servlet.xml (Updated to support validation)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
@darbyluv2code
darbyluv2code / add-student-form.jsp
Created June 13, 2017 10:32
add-student-form.jsp (Fixed form fields)
<!DOCTYPE html>
<head>
<h2>Add Student</h2>
</head>
<body>
<form action="StudentControllerServlet" method="GET">
@darbyluv2code
darbyluv2code / hib-buildpath.png
Last active June 18, 2017 16:18
Hibernate Build Path
hib-buildpath.png
@darbyluv2code
darbyluv2code / StudentControllerServlet.java
Created June 20, 2017 12:01
student-tracker app bug fixes
package com.luv2code.web.jdbc;
import java.io.IOException;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
@darbyluv2code
darbyluv2code / RandomFortuneService.java
Created June 22, 2017 15:52
RandomFortuneService - girlfriends
package com.joelvirux.annotations;
import java.util.Random;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
@darbyluv2code
darbyluv2code / Milos - Sort ORder
Created June 28, 2017 17:40
Milos - Sort Order
1. Update the form for sorting drop-down list
To pass the sortfield, we give a named parameter: "thesortfield". Also, update the options to use the same field names as our Hibernate entities. The form also includes a submit button to send data to the controller.
<form action="${pageContext.request.contextPath}/customer/list">
<select name="thesortfield">
<option value="firstName">First Name</option>
<option value="lastName">Last Name</option>