ElTest.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% int i=3; out.println("i = "+ i); request.setAttribute("ia", 3); request.setAttribute("ia2", 3); %> <p> i = <%=i >4%> </p> i =${ia > 4} <p> i = <%="3" +4%> </p> i =${ia2 + 4} </body> </html>
i = 3 i = false i =false i = 34 i =7
ElCul.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <jsp:include page="Header.jsp" /> </head> <body> <% String exp2 = request.getParameter("exp2"); if(exp2==null) exp2="+"; %> <div style="margin-top: 50px;"></div> <div class="row"> <div class="col-xs-3 col-sm-3"></div> <div class="col-xs-8 col-sm-8"> <form class="form-inline" action="ElCul.jsp" method="post"> <div class="form-group"> <input type="text" name="exp1" class="form-control" value="${param.exp1}"> </div> <div class="form-group"> <select name="exp2" class="form-control"> <option value="+" <% if(exp2.equals("+")) out.write("selected"); %>>+</option> <option value="-" <% if(exp2.equals("-")) out.write("selected"); %>>-</option> <option value="*" <% if(exp2.equals("*")) out.write("selected"); %>>*</option> <option value="/" <% if(exp2.equals("/")) out.write("selected"); %>>/</option> </select> </div> <div class="form-group"> <input type="text" name="exp3" class="form-control" value="${param.exp3 }" > </div> <div class="form-group"> <label>=</label> <% if (exp2.equals("+")) { %> <input type="text" name="exp4" class="form-control" value="${ param.exp1 + param.exp3 }" readonly="readonly"> <% } else if (exp2.equals("-")) { %> <input type="text" name="exp4" class="form-control" value="${ param.exp1 - param.exp3 }" readonly="readonly"> <% } else if (exp2.equals("*")) { %> <input type="text" name="exp4" class="form-control" value="${ param.exp1 * param.exp3 }" readonly="readonly"> <% } else if (exp2.equals("/")) { %> <input type="text" name="exp4" class="form-control" value="${ param.exp1 / param.exp3 }" readonly="readonly"> <% } %> </div> <div class="form-group"> <input type="submit" class="btn btn-success" value="결과 보기"> </div> </form> </div> </div> </body> </html>
ElCulProc.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <div style="margin-top: 50px;"></div> <div class="row"> <div class="col-xs-2 col-sm-2"></div> <div class="col-xs-8 col-sm-8"> <% String exp2 = request.getParameter("exp2"); if (exp2.equals("+")) { %> ${ param.exp1 + param.exp3 } <% } else if (exp2.equals("-")) { %> ${ param.exp1 - param.exp3 } <% } else if (exp2.equals("*")) { %> ${ param.exp1 * param.exp3 } <% } else if (exp2.equals("/")) { %> ${ param.exp1 / param.exp3 } <% } %> </div> </div> </body> </html>
동영상 강좌와 다르게 모바일 적용이 가능한 반응형 부트스트랩을 사용하였다.
여기서는 jsp 를 배우는 강좌 이기 때문에 html 적 요소에는 비중있게 생각 하지 않아도 될 것이다.
또한, 일부 자바 코드는 제 입맛에 맞게 변경 하였습니다.
혹시, 이 강의를 들으면서 제 글을 읽고 소스코드를 참조하는 수강생이 있다면 동영상의 코드와 다르다고 생각지 마세요. 대부분 동여상 내용과 같으니 학습에 도움이 될거라 생각 합니다.
소스 : https://github.com/braverokmc79/jsp_sin
유튜브 동영상 출처 :
강사 : 신형섭(잭임연구원)
저작권 : (주)소프트캠퍼스 http://www.softcampus.co.kr 더많은 무료 강의는 사이트에서 확인하실수 있습니다.
댓글 ( 4)
댓글 남기기