# 2021.04.26(月)① ###### tags: `JV27` `授業ノート` ```htmlembedded= // kokushi2.jsp <%@ page contentType="text/html;charset=UTF-8" %> <% response.setContentType("text/html; charset=UTF-8"); %> <% String name = request.getAttribute("name").toString(); String gakunen = request.getAttribute("gakunen").toString(); String gozen = request.getAttribute("gozen").toString(); String gogo = request.getAttribute("gogo").toString(); String goukei = request.getAttribute("goukei").toString(); String hantei = request.getAttribute("hantei").toString(); %> <html> <head> <link href="https://cdn.jsdelivr.net/npm/daisyui@0.22.0/dist/full.css" rel="stylesheet"> <title> kokushi2.jsp </title> </head> <body> <section class="h-screen flex flex-col"> <header class="text-gray-600 body-font shadow mb-5"> <div class="container mx-auto flex flex-wrap p-5 flex-col md:flex-row items-center"> <a href="/JV27/kokushi2.html" class="flex title-font font-medium items-center text-gray-900 mb-4 md:mb-0"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-10 h-10 text-white p-2 bg-indigo-500 rounded-full" viewBox="0 0 24 24"> <path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"></path> </svg> <span class="ml-3 text-xl">国家試験判定</span> </a> </div> </header> <main class="p-5"> <a href="/JV27/kokushi2.html"> <button class="btn btn-accent btn-sm pr-6"> <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 17l-5-5m0 0l5-5m-5 5h12" /> </svg>もどる</button> </a> <div class="flex-grow text-center text-2xl"> 国家試験判定 <br><br> <span class="text-indigo-500 text-5xl"> <%= gakunen %> </span> 年生の <span class="text-yellow-500 text-5xl"> <%= name %> </span> さん <br> あなたの得点は <br> 午前 <span class="text-purple-500 text-5xl"> <%= gozen %> </span> 点 <br> 午後 <span class="text-pink-500 text-5xl"> <%= gogo %> </span> 点 <br> 合計 <span class="text-green-500 text-5xl"> <%= goukei %> </span> 点 <br> 判定結果 <span class="text-red-500 text-5xl"> <%= hantei %> </span> </div> </main> </body> </html>``` ```java= // kokushi2.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class kokushi2 extends HttpServlet { public void doPost ( HttpServletRequest req, HttpServletResponse res ) throws ServletException , IOException { req.setCharacterEncoding("UTF-8"); res.setContentType("text/html; charset=UTF-8"); String nameStr = req.getParameter("NAME"); String gakunenStr = req.getParameter("GAKUNEN"); String gozenStr = req.getParameter("GOZEN"); Integer gozenInt = Integer.parseInt(gozenStr); String gogoStr = req.getParameter("GOGO"); Integer gogoInt = Integer.parseInt(gogoStr); int goukeiInt = gozenInt + gogoInt; String hantei = ""; if (gozenInt >= 65 && gogoInt >= 65 && goukeiInt >= 140) { hantei = "合格"; } else { hantei = "不合格"; } req.setAttribute("name", nameStr); req.setAttribute("gakunen", gakunenStr); req.setAttribute("gogo", gogoStr); req.setAttribute("gozen", gozenStr); req.setAttribute("goukei", goukeiInt); req.setAttribute("hantei", hantei); ServletContext sc = getServletContext(); sc.getRequestDispatcher("/kokushi2.jsp").forward(req, res); } } ``` ```htmlembedded= // kokushi2.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://cdn.jsdelivr.net/npm/daisyui@0.22.0/dist/full.css" rel="stylesheet"> <title>Document</title> </head> <body> <section class="h-screen flex flex-col"> <header class="text-gray-600 body-font shadow mb-5"> <div class="container mx-auto flex flex-wrap p-5 flex-col md:flex-row items-center"> <a href="/JV27/kokushi2.html" class="flex title-font font-medium items-center text-gray-900 mb-4 md:mb-0"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="w-10 h-10 text-white p-2 bg-indigo-500 rounded-full" viewBox="0 0 24 24"> <path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"></path> </svg> <span class="ml-3 text-xl">国家試験判定</span> </a> </div> </header> <div class="flex-grow flex justify-center items-center"> <form action="./servlet/kokushi2" method="POST"> <div class="card shadow-lg px-16 py-5"> <label class="label"> <span class="label-text">名前</span> </label> <input type="text" name="NAME" class="input input-accent input-bordered"> <label class="label"> <span class="label-text">学年</span> </label> <select name="GAKUNEN" class="select select-bordered select-accent max-w-xs"> <option value="1">1年生</option> <option value="2">2年生</option> <option value="3">3年生</option> <option value="4">4年生</option> </select> <label class="label"> <span class="label-text">午前得点</span> </label> <input type="text" name="GOZEN" class="input input-accent input-bordered"> <label class="label"> <span class="label-text">午後得点</span> </label> <input type="text" name="GOGO" class="input input-accent input-bordered"> <div class="py-5"> <button type="submit" class="btn btn-accent">このボタンを押してね!</button> <button type="reset" class="btn btn-accent btn-outline">クリア</button> </div> </div> </form> </div> </section> </body> </html> ``` ## 雑談 (0→やまぴ 1→みや 2→やすい 3→りょうくん) 1.クラスメソッドの書類通過した!