코딩왕초보
30
2021-06-11 17:33:10
1
111

jsp 게시판을 만드는데 오류가 자꾸 발생합니다 도와주세요 ㅜㅠ



<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="src/wboard.css">
<script>

function formCheck(){
	var title=document.forms[0].title.value;
	var writer=document.forms[0].writer.value;
	var regdate=document.forms[0].regdate.value;
	var content=document.forms[0].content.value;
	
	if(title==null||title==""){
		alert("제목을 입력하세요.");
		document.forms[0].title.focus();
		return false;
	}
	if(writer==null||writer==""){
		alert("작성자를 입력하세요.");
		document.forms[0].writer.focus();
		return false;
	}
	if(regdate==null||regdate==""){
		alert("날짜를 입력하세요.");
		document.forms[0].regdate.focus();
		return false;
	}
	if(content==null||content==""){
			alert("날짜를 입력하세요.");
			document.forms[0].regdate.focus();
			return false;
	}
	return true;
}
</script>
</head>
<body>
<div id="menu">
	<div id="menu_title">
		<h1>글 작성하기</h1>
	</div>
	<div class="section">
		<h2>글 작성하기</h2>
		<div class="write-box">
			<form class="write-form" action="insert.jsp" method="post" onsubmit="return formCheck();">
				<label for=title>제목</label> 
				<input type="text" name="title" id="title" class="title" required/><br>
				<label for=title>작성자</label>
				<input type="text" name="writer" id="title class="writer" required/><br>
				<label for=title>내용</label>
				<textarea rows="20" cols="10"0 name=content id="content" class="content"></textarea><br>
				
				<input type="submit" value="글 올리기"/>
				<input type="reset" value="다시 작성하기" />
			</form>
		</div>
	</div>
</div>
</body>
</html>

write.jsp로 게시글 작성 페이지를 코딩해서 


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>게시글 목록</title>
<link rel="stylesheet" href="src/wboard.css">
<script>
/* function delcheck() {
	result = confirm("정말로 삭제하시겠습니까 ?");

	if(result == true){
		return true;
	}else{
		return false;
	}	
} */
</script>
<script>
var modal = document.getElementById('delete-alert');

window.onclick = function(e){
	if(e.target == modal){
		modal.style.display="none";
	}
}
</script>
</head>
<%
	String idx = request.getParameter("idx");
	
	//데이터베이스 연결관련 변수 선언
	Connection con = null;
	PreparedStatement pstmt = null;
	
	try {
		String driverName = "oracle.jdbc.driver.OracleDriver";
		String url = "jdbc:oracle:thin:@localhost:1521:xe";
		ResultSet rs = null;
		
		Class.forName(driverName); //드라이버 로드
		con = DriverManager.getConnection(url,"board","board");
		//out.println("Oracle데이타베이스 db에 성공적으로 접속했습니다.");
		
		String sql ="select * from board where idx ="+idx;
		
		pstmt = con.prepareStatement(sql);
		rs = pstmt.executeQuery(sql);
		while (rs.next()){
%>

<body>
<div id="menu">
	<div id="menu-title">
		<h1>게시물 조회</h1>
	</div>
	<div class="content-box">
		<div class="title"><%=rs.getString("title") %></div>
		<div class="regdate"><%=rs.getString("regdate") %></div>
		<div class="content"><%=rs.getString("content") %></div>
	</div>
	<a class="delete-btn button" 
		onclick="document.getElementById('delete-alert').style.display='block'">게시글 삭제</a>
	<a class="update-btn button" href="update.jsp?idx=<%=rs.getString("idx")%>">수정</a>
	<a class="list-btn button" href="index.jsp">목록으로</a>	
</div>

<div id="delete-alert">
	<div class="box-inside">
		<p>글을 삭제하겠습니까?</p>
		<a class="delete-yes button" href="delete.jsp?idx=<%=rs.getString("idx")%>">삭제</a>
		<a class="cancel-btn button" onclick="document.getElementById('delete-alert').style.display='none'">취소</a>
	</div>
</div>


<%
		}
		
	} catch (Exception e) {
		out.println("Oracle 데이타베이스 db접속에 문제가 있습니다.");
		out.println(e.getMessage());
		e.printStackTrace();
	} finally {
		pstmt.close();
		con.close();
	}
%>
</body>
</html>


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="src/wboard.css">
</head>
<%
	//데이터베이스 연결관련 변수 선언
	Connection con = null;
	PreparedStatement pstmt = null;
	
	try {
		String driverName = "oracle.jdbc.driver.OracleDriver";
		String url = "jdbc:oracle:thin:@localhost:1521:xe";
		ResultSet rs = null;
		
		Class.forName(driverName); //드라이버 로드
		con = DriverManager.getConnection(url,"board","board");
		//out.println("Oracle데이타베이스 db에 성공적으로 접속했습니다.");
		
		String sql ="select idx, title, writer, to_char(regdate, 'yyyy-mm-dd') regdate, content from board order by idx desc";
		
		pstmt = con.prepareStatement(sql);
		rs = pstmt.executeQuery(sql);
%>

<body>

	<div id="menu">
	  <div id="menu_title">
	      <h1>게시글 리스트</h1>
	      
	  </div>
	  
	  <div class="section">
	     <h2>커뮤니티</h2>
	      <div class="table_layout">
	          <ul class="list">
                  <li class="table_th">
                      <div class="num dpnone">번호</div>
                      <div class="th_subject">제목</div>
                      <div>작성자</div>
                      <div class="date dpnone">등록일</div>                     
				 </li>
				 </ul>
				 </div>
				 </div>
<%	
	while(rs.next()){
		out.print("<li class='table_tr'>");
		out.print("<div class='num'>" + rs.getString("idx") +"</div>");
		out.print("<div class='title'><a href='content.jsp?idx="+rs.getString("idx")+"'>" + rs.getString("title") +"</a></div>");
		out.print("<div class='writer'>" + rs.getString("writer") +"</div>");
		out.print("<div class='date'>" + rs.getString("regdate") +"</div>");
		out.print("</li>");
	}
%>
</ul>
	       </div>
	       
	       <a class="write-btn button" href="write.jsp">글쓰기</a>
       
<%	
	} catch (Exception e) {
		out.println("Oracle 데이타베이스 db접속에 문제가 있습니다.");
		out.println(e.getMessage());
		e.printStackTrace();
	} finally {
		pstmt.close();
		con.close();
	}
%>
</body>
</html>


content.jsp와 index.jsp에서 확인하는데 게시글 목록이 안 나타납니다

content.jsp는 아예 무반응이고요



<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.sql.*" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="src/wboard.css">
<script>
/* function delcheck() {
	result = confirm("정말로 삭제하시겠습니까 ?");

	if(result == true){
		return true;
	}else{
		return false;
	}	
} */
</script>

</head>
<%
	String idx = request.getParameter("idx");
	
	//데이터베이스 연결관련 변수 선언
	Connection con = null;
	PreparedStatement pstmt = null;
	
	try {
		String driverName = "oracle.jdbc.driver.OracleDriver";
		String url = "jdbc:oracle:thin:@localhost:1521:xe";
		ResultSet rs = null;
		
		Class.forName(driverName); //드라이버 로드
		con = DriverManager.getConnection(url,"board","board");
		//out.println("Oracle데이타베이스 db에 성공적으로 접속했습니다.");
		
		String sql ="select idx, title, regdate,content from board where idx ="+idx;
		
		pstmt = con.prepareStatement(sql);
		rs = pstmt.executeQuery(sql);
		rs.next();
%>

<body>
<div id="menu">
	<div id="menu-title">
		<h1>update</h1>
		</div>
	<div class="section">
	<h2>글수정</h2>
	<div class="write-box">
		<h1>WRITE</h1>
	</div>
	<div class="section">
		<h2>글 작성하기</h2>
		<div class="write-box">
			<form class="write-form" action="update.jsp?idx=<%=rs.getString("idx") %>" method="post" onsubmit="return formCheck();">
				<label for=retitle>제목</label> 
				<textarea rows="1"  name="retitle" class="retitle" required><%=rs.getString("title") %></textarea>
				<label for="recontent">내용</label>
				<textarea rows="20" cols="10" name=content id="content" class="content"></textarea>
				<input type="submit" value="글수정"/>
				<input type="reset" value="글다시 작성하기"/>
				<a class="list-btn-button" href="index.jsp">목록으로</a>
			</form>
		</div>
	</div>
</div>
</div>
</body>

<script>
var modal = document.getElementById('delete-alert');

window.onclick = function(e){
	if(e.target == modal){
		modal.style.display="none";
	}
}
</script>
<%				
	} catch (Exception e) {
		out.println("Oracle 데이타베이스 db접속에 문제가 있습니다.");
		out.println(e.getMessage());
		e.printStackTrace();
	} finally {
		pstmt.close();
		con.close();
	}
%>
</body>
<div id="menu">
	<div id="menu-title">
		<h1>update</h1>
	</div>
	<div class="section">
	<h2>글 수정하기</h2>
	<div class="write-box">
		<form class="write-form" action="update.jsp?idx=<%rs.getString("idx") %> method="post">
		<label for="retitle">제목</label>
		<textarea rows="1" name="retitle" id="retitle" required><$=rs.getString("title")</textarea>
		</form>
	<textarea rows="20" cols="100" name="recontent" id="recontent" class="content" required><%=rs.getString("content") %></textarea>
	</div>
</html>


게시글을 수정하는 페이지인 update_forn.jsp를 실행하면 다음과 같이 오류가 생깁니다

고수분들의 조언 부탁드립니다 ㅠㅜ빨리 프로젝트를 완성해야 해서요 


0
  • 답변 1

  • onimusha
    8k
    2021-06-11 17:48:03

    update_form.jsp 100 번째 줄에 <% 뒤에 는 (=) 빠졌어요

  • 로그인을 하시면 답변을 등록할 수 있습니다.