Skip to content

Instantly share code, notes, and snippets.

View darbyluv2code's full-sized avatar

Chad Darby darbyluv2code

View GitHub Profile
@darbyluv2code
darbyluv2code / pom.xml
Created January 31, 2018 19:59
Maven POM for Spring MVC validation
<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>com.luv2code</groupId>
<artifactId>spring-mvc-validation-demo</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>spring-mvc-validation-demo</name>
@darbyluv2code
darbyluv2code / Employee.java
Created February 4, 2018 17:13
Java JDBC Tutorial - Part 12.2: Connect Java Swing GUI to a MySQL Database - Create the DAO
package com.luv2code.jdbc.employeesearch.core;
import java.math.BigDecimal;
/**
*
* @author www.luv2code.com
*
*/
public class Employee {
@darbyluv2code
darbyluv2code / pom.xml
Created February 22, 2018 12:55
Maven POM for standalone apps
<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>com.luv2code</groupId>
<artifactId>spring-standalone-demo</artifactId>
<version>1.0</version>
<packaging>war</packaging>
@darbyluv2code
darbyluv2code / test.jsp
Last active February 26, 2018 20:27
JSP - Loop over all scope attributes
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
</head>
<%
String s="John Doe";
pageContext.setAttribute("theStudent", s);
<?xml version="1.0" encoding="UTF-8"?>
<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>edu.drexel.duit</groupId>
<artifactId>spring-boot-web-demo-one</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
@darbyluv2code
darbyluv2code / DemoSecurityConfig.java
Created March 11, 2018 11:47
CRM App Security: Any one can view list, but for add/update/delete they are prompted to login
package com.luv2code.springdemo.config;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
@darbyluv2code
darbyluv2code / CustomerController.java
Created March 11, 2018 18:15
CRM App: How to show Alert Message to user after Successfully Saved Record to db or Update transaction to db
package com.luv2code.springdemo.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:set var="theLocale" value="${not empty param.theLocale ? param.theLocale : pageContext.request.locale }"
scope="session"/>
<fmt:setLocale value="${theLocale}"/>
<fmt:setBundle basename="com.i18n.resources.myLabels"/>
<html>
<body>
@darbyluv2code
darbyluv2code / XML entity replacement
Created April 6, 2018 15:11
XML entity replacement
Replace
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/web_customer_tracker?zeroDateTimeBehavior=convertToNull&useSSL=false"
With
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/web_customer_tracker?zeroDateTimeBehavior=convertToNull&amp;useSSL=false"
Note the use of &amp; as a replacement for &
@darbyluv2code
darbyluv2code / 01-create-user.sql
Created April 8, 2018 17:54
JSP course - MySQL database scripts
CREATE USER 'webstudent'@'localhost' IDENTIFIED BY 'webstudent';
GRANT ALL PRIVILEGES ON * . * TO 'webstudent'@'localhost';