묻고답하기

insertForm.jsp 파일에서 실행 후 추가 하면 insertPro.jsp 파일로 action을 통해 가진다음에
 insertPro.jsp파일에서 response.sendRedirect("list.jsp?id="+id); 을 통해 list.jsp로 가지게 되어있는 구조인데 무엇때문인지 자꾸 insertForm에서 추가를 하면 문제가 추가되지 않았다고만 뜹니다... 꼭 좀 부탁드려요!


 insertForm.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<link rel="stylesheet" href="style.css"/>

<form name="input" method="post" action="insertPro.jsp">
   <table width=600 border=1 bordercolor="black">
    <tr>
      <td class="label"><label for="question">문제</label>
      <td class="content"><input id="question" name="question" type="text" size="100"
          maxlength="50"  autofocus required></td></tr>
    <tr>
      <td align='center'>보기</td><td align='center'>내용</td></tr>
    <tr>
      <td class="label"><label for="ex1">1</label>
      <td class="content"><input id="ex1" name="ex1" type="text"
          size="100"  maxlength="50" required></td></tr>
    <tr>
      <td class="label"><label for="ex2">2</label>
      <td class="content"><input id="ex2" name="ex2" type="text"
          size="100"  maxlength="50" required></td></tr>
    <tr>
      <td class="label"><label for="ex3">3</label>
      <td class="content"><input id="ex3" name="ex3" type="text"
          size="100"  maxlength="50" required></td></tr>
    <tr>
      <td class="label"><label for="ex4">4</label>
      <td class="content"><input id="ex4" name="ex4" type="text"
          size="100"  maxlength="50" required></td></tr>
    <tr>
      <td class="label"><label for="dap">정답</label>
      <td class="content"><input id="dap" name="dap" type="text"
          size="100"  maxlength="50" required></td></tr>
   
    <tr>
      <td align='center' class="label2" colspan="2"><input type="submit" value="출제하기">
         <input type="reset" value="다시작성"></td></tr>
  </table>
</form>

 


insertPro.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>

<% request.setCharacterEncoding("utf-8");%>

<%
   String id = request.getParameter("id");
   String question= request.getParameter("question");
   String ex1 = request.getParameter("ex1");
   String ex2 = request.getParameter("ex2");
   String ex3 = request.getParameter("ex3");
   String ex4 = request.getParameter("ex4");
   String dap = request.getParameter("dap");
   Timestamp reg_date=new Timestamp(System.currentTimeMillis());


   Connection conn=null;
   PreparedStatement pstmt=null;
   String str="";

   try{
   String jdbcUrl="jdbc:mysql://localhost:3306/jsptest?useUnicode=true&characterEncoding=UTF-8";
     String dbId="jspid";
     String dbPass="jsppass";
  
   Class.forName("com.mysql.jdbc.Driver");
   conn=DriverManager.getConnection(jdbcUrl,dbId ,dbPass);
 
   String sql= "insert into member values (?,?,?,?,?,?,?,?)";
     pstmt=conn.prepareStatement(sql);
     pstmt.setString(1,id);
     pstmt.setString(2,question);   
     pstmt.setString(3,ex1);
     pstmt.setString(4,ex2);
     pstmt.setString(5,ex3);
     pstmt.setString(6,ex4);
     pstmt.setString(7,dap);
     pstmt.setTimestamp(8,reg_date);
     pstmt.executeUpdate();
  
     response.sendRedirect("list.jsp?id="+id);
 
  }catch(Exception e){
   e.printStackTrace();
   out.println("문제가 제대로 출제되지 않았습니다.");
  }finally{
   if(pstmt != null)
    try{pstmt.close();}catch(SQLException sqle){}
   if(conn != null)
    try{conn.close();}catch(SQLException sqle){}
  }
 %>

 


list.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<link rel="stylesheet" href="style.css"/>

<td><a href="insertForm.jsp?id">퀴즈출제</a></td>    
<table border=1 cellspacing=0 cellpadding=4>
  <tr  class="label">
   <td>번호</td>
   <td>제목</td>
   <td>출제일시</td>
   <td>삭제</td>
  
  </tr>
<%

 
  Connection conn=null;
  PreparedStatement pstmt=null;
  ResultSet rs=null;             
 
  try{
  String jdbcUrl="jdbc:mysql://localhost:3306/jsptest?useUnicode=true&characterEncoding=UTF-8";
     String dbId="jspid";
     String dbPass="jsppass";
 
  Class.forName("com.mysql.jdbc.Driver");
  conn=DriverManager.getConnection(jdbcUrl,dbId ,dbPass );

  String sql= "select * from id";
  pstmt=conn.prepareStatement(sql);
  rs=pstmt.executeQuery();

  while(rs.next()){
    String id= rs.getString("id");
    String question= rs.getString("question");
       Timestamp reg_date=rs.getTimestamp("reg_date");
      
    
%>
       <tr>
        <td><%=id%></td>
        <td><%=question%></td>
        <td><%=reg_date.toString()%></td>
        <td><a href="deletePro.jsp?id=<%=id%>">삭제</a></td>       
      </tr>
<%  }
  }catch(Exception e){
  e.printStackTrace();
  }finally{
  if(rs != null)
     try{rs.close();}catch(SQLException sqle){}
  if(pstmt != null)
  try{pstmt.close();}catch(SQLException sqle){}
  if(conn != null)
  try{conn.close();}catch(SQLException sqle){}
  }
%>
</table>

글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
이원희884 누리고의 콘텐츠몰 모듈과 애드온 등은 어떤종류입니까? file  
네모세상 버튼 소스좀 짜주시길 부탁드립니다 [6] file 2017.07.21 by 네모세상
Xe쫑 모바일 페이지 이상  
zartin 아이콘샵 겟수 정하기 [2] 2017.07.20 by zartin
케이비씨 Elkha-Gray Steyle 스킨 2단 레이아웃 만드는법을 모르겠어요.ㅠ [1] file 2017.07.20 by 이온디
꽁꽁 모듈스킨 사용법 [1] file 2017.07.20 by 이온디
슈뉴형 댓글을 삭제중인데 딱 그단어만 찾는방법이있을까요? [2] 2017.07.20 by 이온디
울랄라개굴 나야나 복구후.. admin 페이지가 이상합니다 [1] file 2017.07.20 by 이온디
네모세상 사이트 이사/합치기 방법 이건 어떨까요? [1] 2017.07.20 by 이온디
노루 이거 로그인 대문? 어떻게 하나요ㅜㅜ 봐도 모르겠어요ㅜㅜ [1] 2017.07.20 by 이온디
GHIMAYAN 메뉴 링크 이미지를 서브메뉴에서만 사용하고싶습니다. [1] 2017.07.20 by DoorWeb
허허허 한줄메모장 글 출력 오류 도와주세요 file  
lun**** fontawsome, XEicon 함께 사용 가능한 방법 없을까요? [2] 2017.07.19 by lun****
쿠에 sketchbook5 게시판에서 분류를 이미지로 대체가능할까요? [2] 2017.07.18 by 쿠에
JunWooNam 홈페이지 수정 하는 방법좀 알려주세요 [3] 2017.07.18 by sejin7940
어른이빙구 첨부파일 다운로드시 권한없음(모든글 읽어봤는데..도와주세요)  
박성혁 wix에 XE 게시판 연결시 로그인 문제 ㅠ [1] 2017.07.18 by sheis****
sheis**** 게시판 공개 권한 질문 드려요 도와 주세요ㅠㅠ [2] file 2017.07.18 by sheis****
ksm**** sns 미리보기 썸네일 오류  
adachi XE content 위젯, 푸터 겹침 [7] file 2017.07.18 by adachi
키드344 어도비 뮤즈로 홈페이지 제작 중입니다.  
튜닝셀프 포인트 관리에서 게시글조회가 어떤 의미인가요? [2] 2017.07.18 by 튜닝셀프
하얀양말 아이콘샵 모듈 - 아이콘 이미지 관련 질문 file  
홍수영 xe 이미지 엑박현상... (도와주십시오..)  
vvccvv2 XE content 위젯 문제 (제발 도와주세요 ㅠㅠ) [6] 2017.07.17 by vvccvv2
이원희884 누리고의 콘텐츠몰에서 고객의 다운로드에 대해 질문합니다. [3] 2017.07.17 by 이원희884
윤여 누리고 컨텐트몰 사용하시는 분 도움 좀 부탁드려요 [1] file 2017.07.17 by 이원희884
튜닝셀프 혹시 이 모듈 어디서 다운받을 수 있는지 알 수 있을까요? [2] file 2017.07.17 by 튜닝셀프
마키1 구매한 쇼핑몰 스킨에 누리고등의 국내결제 모듈연결시 [1] 2017.07.17 by HowtoXE
알비노 사이트 접속불가 [1] file 2017.07.17 by 임재영