私のプロジェクトが主に機能して、ユーザーが希望するイベントを変更する権限をユーザーに与えます。 ので、最初のページには、モディファイevent.jsp彼は最後列今jspサーブレットで変更したい詳細を使用して、目的のページにユーザーをリダイレクトする方法はありますか?
変更-event.jspを
<%@page import="java.util.ArrayList"%>
<jsp:include page="includes/header.jsp" />
<div>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%
HttpSession session1 = request.getSession();
//String id = request.getParameter("userId");
String driverName = "com.mysql.jdbc.Driver";
String connectionUrl = "jdbc:mysql://localhost:3306/";
String dbName = "technovision";
String userId = "root";
String password = "root";
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
%>
<h2 align="center"><font><strong>Retrieve data from database in jsp</strong></font></h2>
<table align="center" cellpadding="5" cellspacing="5" border="1">
<tr>
</tr>
<tr bgcolor="#A52A2A">
<td><b>Event name</b></td>
<td><b>Registration Amount</b></td>
<td><b>EventHead name</b></td>
<td><b>EventHead contact</b></td>
<td><b>Event Description</b></td>
<td><b>Action</b></td>
</tr>
<%
try{
connection = DriverManager.getConnection(connectionUrl+dbName, userId, password);
statement=connection.createStatement();
String sql ="SELECT * FROM events";
resultSet = statement.executeQuery(sql);
while(resultSet.next()){
session1.setAttribute("eventid",resultSet.getString(1));
session1.setAttribute("eventname",resultSet.getString(2));
session1.setAttribute("registrationamount",resultSet.getString(3));
session1.setAttribute("eventheadname",resultSet.getString(4));
session1.setAttribute("eventheadcontact",resultSet.getString(5));
session1.setAttribute("eventdescription",resultSet.getString(6));
//ArrayList a = new ArrayList();
//a.add(resultSet.getString(1));
//a.add(resultSet.getString(2));
//a.add(resultSet.getString(3));
//a.add(resultSet.getString(4));
//a.add(resultSet.getString(5));
//a.add(resultSet.getString(6));
%>
<tr bgcolor="#DEB887">
<td><%=resultSet.getString("event_name") %></td>
<td><%=resultSet.getString("registration_amount") %></td>
<td><%=resultSet.getString("eventhead_name") %></td>
<td><%=resultSet.getString("eventhead_contact") %></td>
<td><%=resultSet.getString("event_description") %></td>
<td><a href="modify-page.jsp">Modify</a></td>
</tr>
<%
}
} catch (Exception e) {
e.printStackTrace();
}
%>
</table>
</div>
<%@ include file="includes/footer.jsp" %>
<%@include file="includes/scripts.jsp" %>
</body>
</html>
ユーザーの変更ボタンを使用してシステム内に存在するイベントのリストを取得しますですいずれかの変更ボタンをクリックすると、そのページにリダイレクトする必要があります。このページには、クリックされたイベントの詳細をフェッチして編集できますが、ここでは、上の表の最後のデータをmodify-event.jsp httpsessionを使いましたが、間違った方法で推測しています。 はそうボタンを変更をユーザーがクリックすると、私はページ名変更 - page.jspに彼をリダイレクトするとき
モディファイpage.jsp
<%@page import="java.util.ArrayList"%>
<jsp:include page="includes/header.jsp" />
<%--<%@ page import="com.event"%>--%>
<style>
input.eventdescription{
padding-top : 20px;
padding-bottom : 100px;
}
</style>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.*"%>
<%@page import="java.sql.Connection"%>
<%
// ArrayList[] eventname = new ArrayList[10];
// ArrayList[] registrationamount = new ArrayList[10];
// ArrayList[] eventheadname = new ArrayList[10];
// ArrayList[] eventheadcontact = new ArrayList[10];
// ArrayList[] eventdescription = new ArrayList[10];
// ArrayList[] eventid = new ArrayList[10];
//
//HttpSession session1 = request.getSession();
// eventname = (ArrayList[])session1.getAttribute("eventname");
// registrationamount = (ArrayList[])session1.getAttribute("registrationamount");
// eventheadname = (ArrayList[])session1.getAttribute("eventheadname");
// eventheadcontact = (ArrayList[])session1.getAttribute("eventheadcontact");
// eventdescription = (ArrayList[])session1.getAttribute("eventdescription");
// eventid = (ArrayList[])session1.getAttribute("eventid");
%>
<div class="addevent-content" style="background-color:black">
<div class="pattern height-resize">
<div class="container">
<form class="form-horizontal" action="UpdateEvent" method="post"
id="addevent_form" >
<!-- Form Name -->
<center>
<h2 id="registerheading">
<b style="color: gold">Modify Event</b>
</h2>
</center>
<br>
<!-- Text input-->
<div class="form-group">
<label class="col-md-5 control-label" style="color: #fff">Event
Name<abbr title="Required">*</abbr>
</label>
<div class="col-md-5 inputGroupContainer">
<div class="input-group">
<input name="event_name" id="form_fname" placeholder="Event Name"
value='${eventname}' class="form-control" type="text" required>
</div>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-5 control-label" style="color: #fff">Registration Amount<abbr title="Required">*</abbr>
</label>
<div class="col-md-5 inputGroupContainer">
<div class="input-group">
<input name="registration_amount" id="form_lname" placeholder="Registration Amount"
value='${registrationamount}' class="form-control" type="text" required>
</div>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-5 control-label" style="color: #fff">Event Image<abbr
title="Required">*</abbr></label>
<div class="col-md-5 inputGroupContainer">
<div class="input-group">
<input name="event_image" placeholder="Event Image" class="form-control"
value='' type="text" required>
</div>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-5 control-label" style="color: #fff">EventHead Name<abbr
title="Required">*</abbr></label>
<div class="col-md-5 inputGroupContainer">
<div class="input-group">
<input name="eventhead_name" id="password1" placeholder="EventHead Name"
value='${eventheadname}' class="form-control" type="text" required>
</div>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-5 control-label" style="color: #fff">EventHead Contact
<abbr title="Required">*</abbr>
</label>
<div class="col-md-5 inputGroupContainer">
<div class="input-group">
<input name="eventhead_contact" id="password2" placeholder="(+91)"
value='${eventheadcontact}' class="form-control" type="text" required>
</div>
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-5 control-label" style="color: #fff">Event Description<abbr
title="Required">*</abbr></label>
<div class="col-md-5 inputGroupContainer">
<div class="input-group">
<input name="event_description" id="email" placeholder=""
value='${eventdescription}' class="form-control eventdescription" type="text" required>
</div>
</div>
</div>
<!-- Select Basic -->
<input name="event_id"class="form-control"
value='${eventid}' type="hidden" >
<!-- Button -->
<div class="form-group">
<label class="col-md-5 control-label"></label>
<div class="col-md-5">
<br>
<button type="submit" class="btn btn-warning">SUBMIT</button>
</div>
</div>
</form>
</div>
<!-- /.container -->
</div>
<!-- pattern height resize-->
</div>
<%@ include file="includes/footer.jsp" %>
<%@include file="includes/scripts.jsp" %>
</body>
</html>
だから、ユーザーがクリックしたときにボタンを変更することをどのような方法があると変更のためにmodify-page.jsp内の特定のイベントの詳細をデータベースから取得し、ユーザーはsubmitをクリックしてデータベースを更新する必要があります。以下
データベーステーブル "イベント"
私は最初からやります。 MVCパターン。 – mauretto
この最終年度のプロジェクトを提出するまでに15日しか残っていません。時間は私のために少ないです。 – raviloop
は、URL、">Modifyで一意のIDを送信します。次に、modify-page request.getParameter( "id")でidを取得します。 –