Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

need help with the update code in jsp file?

807600Oct 29 2007 — edited Oct 29 2007
Hi everyone!

I am trying to update records in my jsp file but it doesn't seem to work. I have a studentDetails jsp page that displays details of a particular student say student id=6 for example.

When I click on a edit field, the studentDetails_edit.jsp file loads up with a comments text field, that will display text that was already in the field or display nothing if the field was empty in the database.
When I type a text in the comments field and press continue, I want the page to go to the studentdetails.jsp page displaying the updated comments field.

I have tried coding the jsp were it displays studentDetails as student/studentdetails.jsp?aid=6 and when I click on edit it loads the particular student file as studentDetails_edit?aid=6, and displays the corrent txt for the comments field but when I update the comments field and click on continue
it displays the studentDetails page but without the ID, so it displays student/studentDetails.jsp instead of studentDetails.jsp?aid=6. It doesnt pick up the id for some reason and displays empty fields.

Here is my jsp code:
<%@ include file="login_check.jsp"%>

<jsp:useBean id="appForm" class="student.StudentDetails"/>

<%
bre.ccit.utils.FormProcessor fp = new student.utils.FormProcessor(request);

appForm.useDb(db);

int aid = bre.ccit.utils.servletUtils.isNumber(request.getParameter("aid"), 0); 

if ( aid > 0 ) {
	appForm.setApplicationID(aid);
}

if( "Continue".equals(request.getParameter("Submit")) ) { 
	
	fp.setParameters(appForm);
	
	appForm.save();
	
	db.close();
	response.sendRedirect("studentDetails.jsp?aid=" + appForm.getApplicationID());
	return;
}

%>
and Here is the Form with the Fields:
	<form action="studentDetails.jsp" method="post" name="form1">

	<br>
	<table cellpadding="3" class="results"><tr><td><strong>Submitted Date: </strong></td>
	<td class="bg_lightgrey"><%=appForm.getSubmissionDate()%></td>
	</tr>
	<tr>
    <th width="35%"><div align="right">Comments : </div></th>
    <td width="65%"><input name="Comments" type="text" id="Comments" value="<jsp:getProperty name="appForm" property="Comments" />"></td>
    </tr>
	<th width="35%">&nbsp;</th>
	<td width="65%"><input type="submit" name="Submit" value="Continue">                
    <input name="id" type="hidden" id="id" value="<%=aid%>">
	</td></tr>
	</table>
	</form>
Can any one tell me what I may have done wronge, why doesn't it recoginse the ID when I press continue,

Thanks,
Zub
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 26 2007
Added on Oct 29 2007
3 comments
442 views