I try to execute this code it will show the following error:
java.sql.SQLException.Operation not allowed after ResultSet closed
This is my code.in this code itself shows the above error..
<table cellspacing="0">
<%
try{
ResultSet rs1=st.executeQuery("select u.post_id,u.userid,u.post_txt from requestdetails as r inner join user_post as u on r.frdname=u.userid where r.userid='"+id+"'");
while(rs1.next()){
int post_id=rs1.getInt(1);
int fid=rs1.getInt(2);
System.out.println("iiii "+fid);
String text=rs1.getString(3);
System.out.println("txttt "+text);
ResultSet rs3=stat.executeQuery("select * from userdetails where userid='"+fid+"'");
if(rs3.next()){
String na=rs3.getString("username");
System.out.println("username "+na);
String img=rs3.getString("profilepic");
System.out.println("imgee "+img);
%>
<tr>
<td width="5%" style="padding-left:25;" rowspan="2"> <img src="images/<%=img%>" height="60" width="55"> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3" style="padding:7;"><%=rs3.getString("username") %> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td colspan="3" style="padding-left:7;"><%=text %></td>
</tr>
<%
ResultSet rr=st.executeQuery("select * from comment_status where post_id='"+post_id+"'");
while(rr.next()){
int uid=rr.getInt("userid");
String cmt=rr.getString("comment");
ResultSet rrr=stat.executeQuery("select * from userdetails where userid='"+uid+"'");
if(rrr.next()){
%>
<tr>
<td> </td>
<td width="4%" bgcolor="#EDEFF4" style="padding-left:12;" rowspan="2"> <img src="" height="40" width="47"> </td>
<td bgcolor="#EDEFF4" style="padding-left:7;" > <%=rrr.getString("username") %> </td>
<td align="right" rowspan="2" bgcolor="#EDEFF4">
</tr>
<tr>
<td> </td>
<td bgcolor="#EDEFF4" style="padding-left:7;" colspan="2"><%=cmt %></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<%
}
}
%>
<tr>
<td> </td>
<td width="4%" style="padding-left:17;" bgcolor="#EDEFF4" rowspan="2"> <img src="images/" height="33" width="33"> </td>
<td bgcolor="#EDEFF4" colspan="2" style="padding-top:15;">
<form method="post" name="commenting" onSubmit="return blank_comment_check()" action="commentstatus.jsp">
<input type="text" name="comment_txt" placeholder="Write a comment..." maxlength="420" style="width:100px;" id="">
<input type="hidden" name="postid" value="<%=post_id%>">
<input type="hidden" name="userid" value="">
<input type="submit" name="comment" style="display:none;">
</form>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="4"align="right" style="border-top:outset; border-top-width:thin;"> </td>
</tr>
<%
}
}
}catch(Exception e){
e.printStackTrace();
}
%>
</table>
</div>
I don't know what mistake I've done in above code.
After I change the code like this, it's working fine...
Statement stt=con.createStatement();
ResultSet rs1=stt.executeQuery("select u.post_id,u.userid,u.post_txt from requestdetails as r inner join user_post as u on r.frdname=u.userid where r.userid='"+id+"'");
while(rs1.next()){
int post_id=rs1.getInt(1);
int fid=rs1.getInt(2);
System.out.println("iiii "+fid);
String text=rs1.getString(3);
System.out.println("txttt "+text);
Statement st1=con.createStatement();
ResultSet rs3=st1.executeQuery("select * from userdetails where userid='"+fid+"'");
if(rs3.next()){
String na=rs3.getString("username");
System.out.println("username "+na);
String img=rs3.getString("profilepic");
System.out.println("imgee "+img);
I made the mistake of using the same statement for all queries.
When I created different statements object for the solution it works fine.
Related
image of form showing misplaced dropdown field
i have used SO to create some script that shows/hides a div containing a field if the value of a previous field is "UpperGI". This works fine, but what i cannot do is use tr or td tags within the div.
I want the new field to be displayed in a simple table as the previous fields are.
function yesnoCheck(that) {
if (that.value == "UpperGI") {
document.getElementById("ifYes").style.display = '';
} else {
document.getElementById("ifYes").style.display = "none";
}
}
<form name="frm1" action="https://api-mapper.clicksend.com/http/v2/send.php" method="post">
<table style="width:50%">
<tr>
<td>MRN:</td>
<td><input name="customstring" id="mrn" type="text" /></td>
</tr>
<tr>
<td>Specialty:</td>
<td><select id="specialty" onchange="yesnoCheck(this);">
<option value="Breast">Breast</option>
<option value="UpperGI">UpperGI</option>
<option value="Vascular">Vascular</option>
<option value="Unknown">Unknown</option></select>
</td>
</tr>
<tr><td>
<div id="ifYes">
Select Operation:
<select id="Operation">
<option value="LapChole">Lap Chole</option>
</div>
</td></tr>
<tr>
<td></td>
<td><input type="button" value="SUBMIT" onClick="doall()"></td>
</tr>
</table>
</form>
Can anyone tell me what i am doing wrong?
<tr> it's your row, <td> your case.
You can add some css to fix col size
<script>
function yesnoCheck(that) {
if (that.value == "UpperGI") {
document.getElementById("ifYes").style.display = '';
} else {
document.getElementById("ifYes").style.display = "none";
}
}
</script>
<form name="frm1" action="https://api-mapper.clicksend.com/http/v2/send.php" method="post">
<table style="width:50%">
<tr>
<td>MRN:</td>
<td><input name="customstring" id="mrn" type="text" /></td>
</tr>
<tr>
<td>Specialty:</td>
<td><select id="specialty" onchange="yesnoCheck(this);">
<option value="Breast">Breast</option>
<option value="UpperGI">UpperGI</option>
<option value="Vascular">Vascular</option>
<option value="Unknown">Unknown</option></select>
</td>
</tr>
<tr id="ifYes" style="display: none">
<td>Select Operation:</td>
<td>
<select id="Operation">
<option value="LapChole">Lap Chole</option>
</select>
</td></tr>
<tr>
<td></td>
<td><input type="button" value="SUBMIT" onClick="doall()"></td>
</tr>
</table>
</form>
I am unable to locate the date, month and year in bootstrap date picker. While I am trying to inspect the element in calendar, the calendar is getting closed and unable to locate the element.
It should not be a problem to open the page, click the control which is responsible for showing the calendar and invoke WebDriver.getPageSource() function.
Example code (it uses WebDriverWait to ensure that the calendar widget is there as it might be the case it's loaded after DOM is ready due to asynchronous nature of AJAX calls) :
driver.get("https://eonasdan.github.io/bootstrap-datetimepicker/");
new WebDriverWait(driver, 10)
.until(ExpectedConditions
.elementToBeClickable(By
.xpath("//span[contains(#class,'calendar')]")))
.click();
Files.write(Paths.get("response.html"), driver.getPageSource().getBytes(StandardCharsets.UTF_8));
Example output from the above page:
<div class="bootstrap-datetimepicker-widget dropdown-menu bottom"
style="display: block; top: 34px; bottom: auto; left: 0px; right: auto;">
<ul class="list-unstyled">
<li class="collapse in">
<div class="datepicker">
<div class="datepicker-days" style="display: block;">
<table class="table-condensed">
<thead>
<tr>
<th class="prev" data-action="previous"><span
class="glyphicon glyphicon-chevron-left"
title="Previous Month"></span></th>
<th class="picker-switch" data-action="pickerSwitch"
colspan="5" title="Select Month">July 2019
</th>
<th class="next" data-action="next"><span
class="glyphicon glyphicon-chevron-right"
title="Next Month"></span></th>
</tr>
<tr>
<th class="dow">Su</th>
<th class="dow">Mo</th>
<th class="dow">Tu</th>
<th class="dow">We</th>
<th class="dow">Th</th>
<th class="dow">Fr</th>
<th class="dow">Sa</th>
</tr>
</thead>
<tbody>
<tr>
<td data-action="selectDay" data-day="06/30/2019"
class="day old weekend">30
</td>
<td data-action="selectDay" data-day="07/01/2019"
class="day">1
</td>
<td data-action="selectDay" data-day="07/02/2019"
class="day">2
</td>
<td data-action="selectDay" data-day="07/03/2019"
class="day">3
</td>
<td data-action="selectDay" data-day="07/04/2019"
class="day">4
</td>
<td data-action="selectDay" data-day="07/05/2019"
class="day">5
</td>
<td data-action="selectDay" data-day="07/06/2019"
class="day weekend">6
</td>
</tr>
<tr>
<td data-action="selectDay" data-day="07/07/2019"
class="day weekend">7
</td>
<td data-action="selectDay" data-day="07/08/2019"
class="day">8
</td>
<td data-action="selectDay" data-day="07/09/2019"
class="day">9
</td>
<td data-action="selectDay" data-day="07/10/2019"
class="day">10
</td>
<td data-action="selectDay" data-day="07/11/2019"
class="day">11
</td>
<td data-action="selectDay" data-day="07/12/2019"
class="day">12
</td>
<td data-action="selectDay" data-day="07/13/2019"
class="day weekend">13
</td>
</tr>
<tr>
<td data-action="selectDay" data-day="07/14/2019"
class="day weekend">14
</td>
<td data-action="selectDay" data-day="07/15/2019"
class="day">15
</td>
<td data-action="selectDay" data-day="07/16/2019"
class="day">16
</td>
<td data-action="selectDay" data-day="07/17/2019"
class="day">17
</td>
<td data-action="selectDay" data-day="07/18/2019"
class="day">18
</td>
<td data-action="selectDay" data-day="07/19/2019"
class="day">19
</td>
<td data-action="selectDay" data-day="07/20/2019"
class="day weekend">20
</td>
</tr>
<tr>
<td data-action="selectDay" data-day="07/21/2019"
class="day weekend">21
</td>
<td data-action="selectDay" data-day="07/22/2019"
class="day active today">22
</td>
<td data-action="selectDay" data-day="07/23/2019"
class="day">23
</td>
<td data-action="selectDay" data-day="07/24/2019"
class="day">24
</td>
<td data-action="selectDay" data-day="07/25/2019"
class="day">25
</td>
<td data-action="selectDay" data-day="07/26/2019"
class="day">26
</td>
<td data-action="selectDay" data-day="07/27/2019"
class="day weekend">27
</td>
</tr>
<tr>
<td data-action="selectDay" data-day="07/28/2019"
class="day weekend">28
</td>
<td data-action="selectDay" data-day="07/29/2019"
class="day">29
</td>
<td data-action="selectDay" data-day="07/30/2019"
class="day">30
</td>
<td data-action="selectDay" data-day="07/31/2019"
class="day">31
</td>
<td data-action="selectDay" data-day="08/01/2019"
class="day new">1
</td>
<td data-action="selectDay" data-day="08/02/2019"
class="day new">2
</td>
<td data-action="selectDay" data-day="08/03/2019"
class="day new weekend">3
</td>
</tr>
<tr>
<td data-action="selectDay" data-day="08/04/2019"
class="day new weekend">4
</td>
<td data-action="selectDay" data-day="08/05/2019"
class="day new">5
</td>
<td data-action="selectDay" data-day="08/06/2019"
class="day new">6
</td>
<td data-action="selectDay" data-day="08/07/2019"
class="day new">7
</td>
<td data-action="selectDay" data-day="08/08/2019"
class="day new">8
</td>
<td data-action="selectDay" data-day="08/09/2019"
class="day new">9
</td>
<td data-action="selectDay" data-day="08/10/2019"
class="day new weekend">10
</td>
</tr>
</tbody>
</table>
</div>
<div class="datepicker-months" style="display: none;">
<table class="table-condensed">
<thead>
<tr>
<th class="prev" data-action="previous"><span
class="glyphicon glyphicon-chevron-left"
title="Previous Year"></span></th>
<th class="picker-switch" data-action="pickerSwitch"
colspan="5" title="Select Year">2019
</th>
<th class="next" data-action="next"><span
class="glyphicon glyphicon-chevron-right"
title="Next Year"></span></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="7"><span data-action="selectMonth"
class="month">Jan</span><span
data-action="selectMonth"
class="month">Feb</span><span
data-action="selectMonth"
class="month">Mar</span><span
data-action="selectMonth"
class="month">Apr</span><span
data-action="selectMonth"
class="month">May</span><span
data-action="selectMonth"
class="month">Jun</span><span
data-action="selectMonth"
class="month active">Jul</span><span
data-action="selectMonth"
class="month">Aug</span><span
data-action="selectMonth"
class="month">Sep</span><span
data-action="selectMonth"
class="month">Oct</span><span
data-action="selectMonth"
class="month">Nov</span><span
data-action="selectMonth" class="month">Dec</span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="datepicker-years" style="display: none;">
<table class="table-condensed">
<thead>
<tr>
<th class="prev" data-action="previous"><span
class="glyphicon glyphicon-chevron-left"
title="Next Decade"></span></th>
<th class="picker-switch" data-action="pickerSwitch"
colspan="5" title="Select Decade">2014-2025
</th>
<th class="next" data-action="next"><span
class="glyphicon glyphicon-chevron-right"
title="Previous Decade"></span></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="7"><span data-action="selectYear" class="year">2014</span><span
data-action="selectYear"
class="year">2015</span><span
data-action="selectYear"
class="year">2016</span><span
data-action="selectYear"
class="year">2017</span><span
data-action="selectYear"
class="year">2018</span><span
data-action="selectYear"
class="year active">2019</span><span
data-action="selectYear"
class="year">2020</span><span
data-action="selectYear"
class="year">2021</span><span
data-action="selectYear"
class="year">2022</span><span
data-action="selectYear"
class="year">2023</span><span
data-action="selectYear"
class="year">2024</span><span
data-action="selectYear" class="year">2025</span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="datepicker-decades" style="display: none;">
<table class="table-condensed">
<thead>
<tr>
<th class="prev" data-action="previous"><span
class="glyphicon glyphicon-chevron-left"
title="Previous Century"></span></th>
<th class="picker-switch" data-action="pickerSwitch"
colspan="5">1999-2099
</th>
<th class="next" data-action="next"><span
class="glyphicon glyphicon-chevron-right"
title="Next Century"></span></th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="7"><span data-action="selectDecade"
class="decade" data-selection="2005">2000 - 2011</span><span
data-action="selectDecade" class="decade"
data-selection="2017">2012 - 2023</span><span
data-action="selectDecade" class="decade"
data-selection="2029">2024 - 2035</span><span
data-action="selectDecade" class="decade"
data-selection="2041">2036 - 2047</span><span
data-action="selectDecade" class="decade"
data-selection="2053">2048 - 2059</span><span
data-action="selectDecade" class="decade"
data-selection="2065">2060 - 2071</span><span
data-action="selectDecade" class="decade"
data-selection="2077">2072 - 2083</span><span
data-action="selectDecade" class="decade"
data-selection="2089">2084 - 2095</span><span
data-action="selectDecade" class="decade"
data-selection="2101">2096 - 2107</span><span></span><span></span><span></span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</li>
<li class="picker-switch accordion-toggle">
<table class="table-condensed">
<tbody>
<tr>
<td><a data-action="togglePicker" title="Select Time"><span
class="glyphicon glyphicon-time"></span></a></td>
</tr>
</tbody>
</table>
</li>
<li class="collapse">
<div class="timepicker">
<div class="timepicker-picker">
<table class="table-condensed">
<tbody>
<tr>
<td><a href="#" tabindex="-1" title="Increment Hour"
class="btn" data-action="incrementHours"><span
class="glyphicon glyphicon-chevron-up"></span></a>
</td>
<td class="separator"></td>
<td><a href="#" tabindex="-1" title="Increment Minute"
class="btn" data-action="incrementMinutes"><span
class="glyphicon glyphicon-chevron-up"></span></a>
</td>
<td class="separator"></td>
</tr>
<tr>
<td><span class="timepicker-hour"
data-time-component="hours" title="Pick Hour"
data-action="showHours">05</span></td>
<td class="separator">:</td>
<td><span class="timepicker-minute"
data-time-component="minutes" title="Pick Minute"
data-action="showMinutes">46</span></td>
<td>
<button class="btn btn-primary"
data-action="togglePeriod" tabindex="-1"
title="Toggle Period">PM
</button>
</td>
</tr>
<tr>
<td><a href="#" tabindex="-1" title="Decrement Hour"
class="btn" data-action="decrementHours"><span
class="glyphicon glyphicon-chevron-down"></span></a>
</td>
<td class="separator"></td>
<td><a href="#" tabindex="-1" title="Decrement Minute"
class="btn" data-action="decrementMinutes"><span
class="glyphicon glyphicon-chevron-down"></span></a>
</td>
<td class="separator"></td>
</tr>
</tbody>
</table>
</div>
<div class="timepicker-hours" style="display: none;">
<table class="table-condensed">
<tbody>
<tr>
<td data-action="selectHour" class="hour">12</td>
<td data-action="selectHour" class="hour">01</td>
<td data-action="selectHour" class="hour">02</td>
<td data-action="selectHour" class="hour">03</td>
</tr>
<tr>
<td data-action="selectHour" class="hour">04</td>
<td data-action="selectHour" class="hour">05</td>
<td data-action="selectHour" class="hour">06</td>
<td data-action="selectHour" class="hour">07</td>
</tr>
<tr>
<td data-action="selectHour" class="hour">08</td>
<td data-action="selectHour" class="hour">09</td>
<td data-action="selectHour" class="hour">10</td>
<td data-action="selectHour" class="hour">11</td>
</tr>
</tbody>
</table>
</div>
<div class="timepicker-minutes" style="display: none;">
<table class="table-condensed">
<tbody>
<tr>
<td data-action="selectMinute" class="minute">00</td>
<td data-action="selectMinute" class="minute">05</td>
<td data-action="selectMinute" class="minute">10</td>
<td data-action="selectMinute" class="minute">15</td>
</tr>
<tr>
<td data-action="selectMinute" class="minute">20</td>
<td data-action="selectMinute" class="minute">25</td>
<td data-action="selectMinute" class="minute">30</td>
<td data-action="selectMinute" class="minute">35</td>
</tr>
<tr>
<td data-action="selectMinute" class="minute">40</td>
<td data-action="selectMinute" class="minute">45</td>
<td data-action="selectMinute" class="minute">50</td>
<td data-action="selectMinute" class="minute">55</td>
</tr>
</tbody>
</table>
</div>
</div>
</li>
</ul>
</div>
URL oracle = new URL("hurlAddress/dinfo.cgi");
BufferedReader in = new BufferedReader(
new InputStreamReader(oracle.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
I get
<html>
<head>
<!-- RUI RC=100 -->
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Don't open this page!</title>
</head>
<body bgcolor="#C0C0C0">
<center>
<table border="0" cellpadding="0" cellspacing="4" width="400">
<tr><td align="center" valign="top" width="48">
<img src="en/media/ss_wrn.gif" border="0" width=32 height=32>
</td>
<td>
<font size="4" face="Helvetica,Arial">
<b>User information is disabled.</b><br>
This operation cannot be accepted. User certification is invalid or date expired.<br>
Update page.<br>
</font>
</td>
</tr>
<tr><td></td>
<td align="right">
<img src="en/media/b_ok.gif" border="0" alt="OK" title="OK">
</td>
</tr>
</table>
</center>
</body>
I was expecting
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<title>Remote UI:Device Information</title>
</head>
<body bgcolor="white" link="blue" alink="red" vlink="blue">
<a name="page_top"></a>
<form>
<SCRIPT LANGUAGE="JavaScript">
var has_fax = false; // true or false
var Fax_Type = "0"; // 0(None),1(PSTN),2(PSTNx2),3(ISDN)
var has_send =true; // has send
var is_oem = false;
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function reload_device(){
var cgi_str = "./dinfo.cgi?";
// for Expire Cache!!
var now_time = new Date();
cgi_str += "Dummy=" + now_time.getTime();
document.location.href = cgi_str;
}
</SCRIPT>
<table border="0" cellpadding="0" cellspacing="2" width="100%">
<tr>
<td valign="middle"><font size="4" color="#000066"><b><table border="0" cellpadding="0" cellspacing="2">
<tr>
<td rowspan="2" nowrap><img src="en/media/imgs030.gif"></td>
<td nowrap><font face="Helvetica,Arial" size="4" color="#000066"><b>slq29986</b></font></td>
</tr>
<tr>
<td nowrap><font size="2">iR5570</font></td>
</tr>
</table></b></font></td>
<td valign="middle" width="70" align="right"><font size="4" color="black"><b><img src="en/media/bh_updt.gif" width="28" height="28" border="0" alt="Update" title="Update"></b></font></td>
</tr>
</table>
<hr noshade size="2">
<table border="0" cellpadding="0" cellspacing="4" width="100%">
<tr>
<td align="left"><font size="1"> Last Updated :05/26/2016 19:30:54</font></td>
</tr>
</table><table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr height="26">
<td bgcolor="#000066" height="26"><font color="white" face="Helvetica,Arial"><b> Device Information</b></font></td>
</tr>
</table><table border="0" cellspacing="2" cellpadding="2" width="100%">
<SCRIPT LANGUAGE="JavaScript">
if(is_oem == false)
{
document.write('<tr>');
document.write('<td width="3%"></td>');
document.write('<td width="40%"><font face="Helvetica,Arial" size="2">Manufacturer :</font></td>');
document.write('<td><font size="4">CANON INC</font></td>');
document.write('</tr>');
}
</SCRIPT>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Device Name :</font></td>
<td><font size="4">slq29986</font></td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Location :</font></td>
<td><font size="4">MESAAS</font></td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Product Name : </font></td>
<td>iR5570</td>
</tr>
<tr>
<td colspan="3"><hr size="1"></td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Serial Number :</font></td>
<td>SLQ29986</td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Main Board Version :</font></td>
<td>1</td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Controller Version :</font></td>
<td>3604.838.3201</td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Scanner Version :</font></td>
<td>401.100</td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Finisher Version :</font></td>
<td>801</td>
</tr>
<SCRIPT LANGUAGE="JavaScript">
if(has_send == true)
{
document.write('<tr>');
document.write('<td colspan="3">');
document.write('<hr size="1">');
document.write('</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td width="3%"></td>');
document.write('<td width="40%"><font face="Helvetica,Arial" size="2">Receive E-mail Address :</font></td>');
document.write('<td>aaa#aaa.edu</td>');
document.write('</tr>');
}
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
if( has_fax == true )
{
document.write('<tr>');
document.write('<td colspan="3">');
document.write('<hr size="1">');
document.write('</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td width="3%"></td>');
document.write('<td width="40%"><font face="Helvetica,Arial" size="2">Telephone Number :</font></td>');
document.write('<td></td>');
document.write('</tr>');
if( Fax_Type == "3" )
{
document.write('<tr>');
document.write('<td width="3%"></td>');
document.write('<td width="40%"><font face="Helvetica,Arial" size="2">Subaddress :</font></td>');
document.write('<td></td>');
document.write('</tr>');
}
}
</SCRIPT>
<tr>
<td colspan="3">
<hr size="1">
</td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">System Manager :</font></td>
<td>MESAAS</td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Contact Information :</font></td>
<td></td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">E-mail Address :</font></td>
<td></td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Support :</font></td>
<td></td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Administrator Comment (E-mail) :</font></td>
<td></td>
</tr>
<tr>
<td colspan="3">
<hr size="1">
</td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Contact Person :</font></td>
<td></td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Phone :</font></td>
<td></td>
</tr>
<tr>
<td width="3%"></td>
<td width="40%"><font face="Helvetica,Arial" size="2">Comment (E-mail) :</font></td>
<td></td>
</tr>
</table>
<p>
<hr size="2">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td valign="bottom"><img src="en/media/ba_ptp.gif" border="0" hspace="2" vspace="2" alt="Back to the Top on This Page" title="Back to the Top on This Page"></td>
</tr>
</table>
</form>
</body>
</html>
Thanks to amitmah and Gilbert Le Blanc I installed
httpfox addon on firefox and I noticed that I need to set a cookie
URL url = new URL("urlAddress/dinfo.cgi");
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty("Cookie", "iR=7472571");
try (BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()))){
StringBuilder builder = new StringBuilder();
int cp;
while ((cp = in.read()) != -1) {
builder.append((char) cp);
}
return builder.toString();
}
In browser this cookie is set if I access first urlAddress. If I tried to access directly urlAddress/dinfo.cgi I get the same "User information is disabled..." response.
I am trying to insert values id(Not Auto Incr), Eid, Ename, Esalary, Eaddress from mysql table named employee but following exception is showed
java.sql.SQLException: Unknown column 'jay' in 'field list'
1. Insert.jsp
<form method="post" action="Insertbackend.jsp">
<table border="1">
<tr>
<td style="font-size:20px ">Enter Employee ID: </td>
<td><input type="text" name="id" /></td>
</tr>
<tr>
<td style="font-size:20px ">Enter Employee Name: </td>
<td><input type="text" name="En" /></td>
</tr>
<tr>
<td style="font-size:20px ">Enter Employee Salary: </td>
<td><input type="text" name="Es" /></td>
</tr>
<tr>
<td style="font-size:20px ">Enter Employee Address: </td>
<td><input type="text" name="Ea" /></td>
</tr>
<tr>
<td style="border-right:0em;"></td>
<td style="border-left:0em;"><input type="submit" value="Insert"></td>
</tr>
</table>
</form>
2. Insetbackend.jsp
<%
try
{
String eid=(String)request.getParameter("id");
String en=(String)request.getParameter("En");
String es=(String)request.getParameter("Es");
String ea=(String)request.getParameter("Ea");
Class.forName("com.mysql.jdbc.Driver");
Connection c=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");
Statement s=c.createStatement();
s.executeUpdate("insert into employee values("+eid+","+en+","+es+","+ea+")");
c.close();
s.close();
}
catch(Exception e)
{
out.println(e);
}
%>
Edit this line:
s.executeUpdate("insert into employee values("+eid+","+en+","+es+","+ea+")");
in to:
s.executeUpdate("insert into employee values('"+eid+"','"+en+"','"+es+"','"+ea+"')");
Since you are using all strings, you must add the quotes surrounded..
<form action="addCustServlet" method="POST" name="frmAddUser">
<table>
<tr>
<td><h3 class="templatemo-gold">ID Number: </h3></td>
<td>
<input type="text" name="cust_id" size="12" value="<c:out value="${customer.cust_id}" />" /> <br/><br/></td>
</tr>
<tr>
<td><h3 class="templatemo-gold">Name: </h3></td>
<td><input type="text" name="custName" size="50"
value="<c:out value="${customer.custName}" />" /> <br/><br/></td>
</tr>
<tr>
<td><h3 class="templatemo-gold">Address: </h3></td>
<td><input type="text" name="custAdd" size="50"
value="<c:out value="${customer.custAdd}" />" /><br/><br/></td>
</tr>
<tr>
<td><h3 class="templatemo-gold">Region: </h3></td>
<td><input type="text" name="custRegion" size="50"
value="<c:out value="${customer.custRegion}" />" /><br/><br/></td>
</tr>
<tr>
<td><h3 class="templatemo-gold">Handphone No: </h3></td>
<td><input type="text" name="custHandphoneNo" size="50"
value="<c:out value="${customer.custHandphoneNo}" />" />><br/><br/></td>
</tr>
<tr>
<td><h3 class="templatemo-gold">Phone No: </h3></td>
<td><input type="text" name="custPhoneNo" size="50"
value="<c:out value="${customer.custPhoneNo}" />" /><br/><br/></td>
</tr>
<tr>
<td><h3 class="templatemo-gold">Email: </h3></td>
<td><input type="text" name="custEmail" size="50"
value="<c:out value="${customer.custEmail}" />" /><br/><br/></td>
</tr>
<tr>
<td> <input type="submit" name="submit" class="btn text-uppercase templatemo-btn templatemo-info-btn">Submit </td>
</tr>
</table>
</form>
Whenever I try to insert data using jsp form, it keeps executing nullPointerException as my cust_id is not auto generated or auto increment.
After I click addbutton, servlet sent to updateUser and data cannot be inserted.
Customer customer = new Customer();
customer.setCustName(request.getParameter("custName"));
customer.setCustAdd(request.getParameter("custAdd"));
customer.setCustRegion(request.getParameter("custRegion"));
customer.setCustHandphoneNo(request.getParameter("custHandphoneNo"));
customer.setCustPhoneNo(request.getParameter("custPhoneNo"));
customer.setCustEmail(request.getParameter("custEmail"));
String cust_id = request.getParameter("cust_id");
if(cust_id == null || cust_id.isEmpty())
{
dao.addUser(customer);
}
else
{
customer.setCust_id(cust_id);
dao.updateUser(customer);
}
RequestDispatcher view = request.getRequestDispatcher(LIST_USER);
request.setAttribute("customer", dao.getAllCustomer());
view.forward(request, response);
}