chrome 에서 이상 없으나 explore 에서 화면이 깨지는 경우 아래 meta 테그 추가 하면 됩니다.
1 2 3 |
<meta http-equiv="X-UA-Compatible" content="IE=Edge;" /> |
그래도 깨지는 경우 맨위에 dtd 추가 하면 됩니다.
chrome 에서 이상 없으나 explore 에서 화면이 깨지는 경우 아래 meta 테그 추가 하면 됩니다.
1 2 3 |
<meta http-equiv="X-UA-Compatible" content="IE=Edge;" /> |
그래도 깨지는 경우 맨위에 dtd 추가 하면 됩니다.
html 로 보기 persons.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
<breakfast_menu> <food> <name>Belgian Waffles</name> <price>$5.95</price> <description>Two of our famous Belgian Waffles with plenty of real maple syrup</description> <calories>650</calories> </food> <food> <name>Strawberry Belgian Waffles</name> <price>$7.95</price> <description>Light Belgian waffles covered with strawberries and whipped cream</description> <calories>900</calories> </food> <food> <name>Berry-Berry Belgian Waffles</name> <price>$8.95</price> <description>Light Belgian waffles covered with an assortment of fresh berries and whipped cream</description> <calories>900</calories> </food> <food> <name>French Toast</name> <price>$4.50</price> <description>Thick slices made from our homemade sourdough bread</description> <calories>600</calories> </food> <food> <name>Homestyle Breakfast</name> <price>$6.95</price> <description>Two eggs, bacon or sausage, toast, and our ever-popular hash browns</description> |
persons.xsl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<?xml version="1.0" encoding="UTF-8"?> <html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE"> <xsl:for-each select="breakfast_menu/food"> <div style="background-color:teal;color:white;padding:4px"> <span style="font-weight:bold"><xsl:value-of select="name"/> - </span> <xsl:value-of select="price"/> </div> <div style="margin-left:20px;margin-bottom:1em;font-size:10pt"> <p> <xsl:value-of select="description"/> <span style="font-style:italic"> (<xsl:value-of select="calories"/> calories per serving)</span> </p> </div> </xsl:for-each> </body> </html> |
XsltTransformation.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; import java.io.File; public class XsltTransformation { private static Document document; public static void main(String[] args) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); File xml = new File("D:\\persons.xml"); File xsl = new File("D:\\persons.xsl"); DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.parse(xml); // Use a Transformer for output TransformerFactory transformerFactory = TransformerFactory.newInstance(); StreamSource style = new StreamSource(xsl); Transformer transformer = transformerFactory.newTransformer(style); DOMSource source = new DOMSource(document); StreamResult result = new StreamResult(System.out); transformer.transform(source, result); } } |
The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path 1. 작성중 프로젝트 폴더에서 왼쪽 마우스 -> Properties 선택 2. Proejct Facets -> java -> Runtimes 의 Apache Tomcet v8.0 버전 체크 후 APPLY
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
package test02; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.io.PrintWriter; import java.io.StringWriter; public class test01 { private static final String USER_AGENT = "Mozilla/5.0"; private static final String GET_URL = "https://data.auctionpro.co.kr/airline?code=ke"; private static final String POST_URL = "https://data.auctionpro.co.kr/airline"; private static final String POST_PARAMS = "code=oz"; public static void main(String[] args) throws IOException { sendGET(); System.out.println("GET DONE"); sendPOST(); System.out.println("POST DONE"); } private static void sendGET() throws IOException { URL obj = new URL(GET_URL); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); try { con.setRequestMethod("GET"); con.setRequestProperty("User-Agent", USER_AGENT); con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); con.setRequestProperty("Content-Length", "length"); //con.setRequestProperty("Accept-Charset", "UTF-8"); int responseCode = con.getResponseCode(); //GET Response Code :: 200 System.out.println("GET Response Code :: " + responseCode); if (responseCode == HttpURLConnection.HTTP_OK) { // success BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(),"UTF-8")); String inputLine = null; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine).append("\r\n"); } in.close(); // print result System.out.println(response.toString()); } else { System.out.println("GET request not worked"); } } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); sw.toString(); // stack trace as a string System.out.println(sw.toString()); } finally { if (con != null) { con.disconnect(); } } } private static void sendPOST() throws IOException { URL obj = new URL(POST_URL); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); try { con.setRequestMethod("POST"); con.setRequestProperty("User-Agent", USER_AGENT); // For POST only - START con.setDoOutput(true); OutputStream os = con.getOutputStream(); os.write(POST_PARAMS.getBytes()); os.flush(); os.close(); // For POST only - END int responseCode = con.getResponseCode(); System.out.println("POST Response Code :: " + responseCode); if (responseCode == HttpURLConnection.HTTP_OK) { //success BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream(),"UTF-8")); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine).append("\r\n");; } in.close(); // print result System.out.println(response.toString()); } else { System.out.println("POST request not worked"); } } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); sw.toString(); // stack trace as a string System.out.println(sw.toString()); } finally { if (con != null) { con.disconnect(); } } } } |
페이지 이동 방법 1. Forward – request 스코프에 담긴 값이 다음 페이지에 전달된다. – 이동된 페이지지 주소가 화면에 안보임(기존 페이지 주소와 같음)
1 2 3 4 5 6 7 8 9 |
1) <% pageContext.forward("https://google.com"); %> 2) <jsp:forward page="https://google.com"/>; 3) <% RequestDispatcher rd = request.getRequestDispatcher("https://google.com"); rd.forward(request.response); %> |
2. Redirect – 클라이언트가 새로운 페이지를 요청한 것과 같이 페이지 이동 – 이동된 페이지지 주소가 화면에 보임(기존 페이지 주소와 다름)
1 2 3 4 5 |
<% response.sendRedirect("https://www.google.com"); %> |
참조 : https://installed.tistory.com/entry/8-JSP-%ED%8A%B9%EC%A0%95%ED%8E%98%EC%9D%B4%EC%A7%80%EB%A1%9C-%EC%9D%B4%EB%8F%99%EB%B0%A9%EB%B2%95
/common/footer.jsp
1 2 3 4 5 6 7 8 9 10 11 |
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <div data-role="footer"> <p class="version"> v2.0</p> <p>Copyrightⓒ 2020 Korea </p> <div style="text-align:center;"> <a href="javascript:goInfo();" class="InfoBtn" data-role="none"><font color='#ffffff'>정보</font></a> <a href="tel:02-2222-2222" class="lnfoBtn" data-role="none"><font color='#ffffff'>헬프데스크 02-2222-2222</font></a> </div> </div> |
Main.jsp 아래에 추가
1 2 3 |
<jsp:include page="/common/footer.jsp" /> |
1 2 3 4 5 6 7 |
$(document).on('click', '#NewTabBtn', function() { //location.href="https://google.com/"; window.open("https://google.com/", "_blank"); }); |
1 2 3 4 5 6 7 8 |
if(request.isSecure()){ //2020-10-28 http ->https 로 수정 response.sendRedirect("https://"+ request.getServerName()+"/"+sAccess+"/template/Loading.jsp?Local="+ Local); return ""; }else{ return "/"+sAccess+"/template/Loading.jsp"; } |
Servlet 처리시 Https로 접근되었는지 확인이 필요한때가 있다. 최근 정보통신부에서 고시하기로, 회원정보, 금융거래와 같이 보안에 취약할 수 있는 항목에 대해서는 https 프로토콜을 이용하여 처리를 수행하도록 되어 있는데. 서버단에서 이러한 https요청으로 request가 들어왔는지 확인 하는 메소드로 HttpServletRequest 클래스내에 isSeucre()라는 메소드가 있다. true라면 https로 접근된 것이며, false라면 일반 경로로 (http)로 접근된 것을 의미한다.
로컬에서 에러
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
HTTP Status 500 - java.io.FileNotFoundException: D:\workspace\Example2\WebContent\WEB-INF\classes\resource\ActionConfig.properties (지정된 경로를 찾을 수 없습니다) type Exception report message java.io.FileNotFoundException: D:\workspace\Example2\WebContent\WEB-INF\classes\resource\ActionConfig.properties (지정된 경로를 찾을 수 없습니다) description The server encountered an internal error that prevented it from fulfilling this request. exception javax.servlet.ServletException: java.io.FileNotFoundException: D:\workspace\Example2\WebContent\WEB-INF\classes\resource\ActionConfig.properties (지정된 경로를 찾을 수 없습니다) com.finix.common.ctrl.CommonActionCtrl.init(CommonActionCtrl.java:55) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476) java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Unknown Source) root cause |
서버에서 에러
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
HTTP Status 500 – Internal Server Error Type Exception Report Message java.io.FileNotFoundException: /WEB-INF/classes/resource/ActionConfig.properties (그런 파일이나 디렉터리가 없습니다) Description The server encountered an unexpected condition that prevented it from fulfilling the request. Exception javax.servlet.ServletException: java.io.FileNotFoundException: /WEB-INF/classes/resource/ActionConfig.properties (그런 파일이나 디렉터리가 없습니다) com.finix.common.ctrl.CommonActionCtrl.init(CommonActionCtrl.java:55) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:476) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:748) Root Cause java.io.FileNotFoundException: /WEB-INF/classes/resource/ActionConfig.properties (그런 파일이나 디렉터리가 없습니다) java.io.FileInputStream.open0(Native Method) java.io.FileInputStream.open(FileInputStream.java:195) java.io.FileInputStream.<init>(FileInputStream.java:138) java.io.FileInputStream.<init>(FileInputStream.java:93) com.finix.common.ctrl.CommonActionCtrl.init(CommonActionCtrl.java:32) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:476) org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498) org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:748) Note The full stack trace of the root cause is available in the server logs. |
수정위치 서버 수정 : 경로명을 풀로 적어 준다.
1 2 3 4 5 6 7 8 9 10 11 |
<servlet> <servlet-name>Controller</servlet-name> <servlet-class>com.finix.common.ctrl.CommonActionCtrl</servlet-class> <init-param> <param-name>actionConfig</param-name> <param-value>/home/world/New/ROOT/WEB-INF/classes/resource/ActionConfig.properties</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> |
1 2 3 4 5 6 |
org.eclipse.epp.logging.aeri.ide --> Missing Constraint: Import-Package: org.apache.lucene.document; version = "[7.1.0,8.0.0]" org.apache.lucene.index; version = "[7.1.0,8.0.0]" org.apache.lucene.search; version = "[7.1.0,8.0.0]" org.apache.lucene.store; version = "[7.1.0,8.0.0]" |