Skip to content

Instantly share code, notes, and snippets.

View darbyluv2code's full-sized avatar

Chad Darby darbyluv2code

View GitHub Profile
@darbyluv2code
darbyluv2code / Student.java
Created August 10, 2017 05:31
updates to jsp web student tracker
package com.mytest.jdbc;
public class Student {
private int id;
private String firstName;
private String lastName;
private String email;
public Student(int id, String firstName, String lastName, String email) {
this.id = id;
@darbyluv2code
darbyluv2code / StudentTwo.java
Created August 23, 2017 05:18
JSF - drop-down lists
package com.luv2code.jsf.hello;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
@ManagedBean
public class StudentTwo {
@darbyluv2code
darbyluv2code / todo-demo.jsp
Created August 24, 2017 15:12
JSP course - session demo
<%@ page import="java.util.*" %>
<html>
<body>
<!-- Step 1: Create HTML form -->
<form action="todo-demo.jsp">
Add new item: <input type="text" name="theItem" />
@darbyluv2code
darbyluv2code / Student.java
Created November 17, 2017 22:17
Spring MVC - Fix for no bean found
package com.luv2code.springdemo.mvc;
import java.util.LinkedHashMap;
public class Student {
private String firstName;
private String lastName;
private String favoriteLanguage;
@darbyluv2code
darbyluv2code / table-setup.sql
Created November 26, 2017 15:15
YouTube - creates table AND stored procedure
create database if not exists demo;
use demo;
drop table if exists employees;
CREATE TABLE `employees` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`last_name` varchar(64) DEFAULT NULL,
`first_name` varchar(64) DEFAULT NULL,
@darbyluv2code
darbyluv2code / Cast.java
Created December 7, 2017 22:16
communicating with casts
package vikram;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
@Component
public class Cast implements employee
{
//Field injection through annotation ensures that there is no need for setter methods to be defined.
@darbyluv2code
darbyluv2code / DemoSecurityConfig.java
Created December 22, 2017 18:22
updates from Spring Security 5
package com.luv2code.springsecurity.demo.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.User.UserBuilder;
@Configuration
@darbyluv2code
darbyluv2code / fancy-login.jsp
Created January 3, 2018 18:14
fancy-login.jsp updates (see line 57)
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="en">
<head>
<title>Login Page</title>
<meta charset="utf-8">
@darbyluv2code
darbyluv2code / CustomerDAOImpl.java
Created January 15, 2018 15:50
CustomerDAOImpl.java (check that you have the same imports)
package com.luv2code.springdemo.dao;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@darbyluv2code
darbyluv2code / pom.xml for Standalone Apps
Created January 22, 2018 05:26
Do you already have a pom.xml file that I can use with Maven?
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>spring-hibernate-for-beginners</groupId>
<artifactId>spring-demo-app</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<properties>
<springframework.version>5.0.2.RELEASE</springframework.version>