In a JSP Page, onclick of submit, it is submitting twice.
Hello! everybody...
Please help me.. its urgent!
I have a jsp page, after i enter values in textboxes and click on submit, i am calling a javascript function wherein i am submitting the form.
The problem is, it is submitting twice and inserting the record in the database twice.
here is my code.
anybody pls let me know where the problem is?
Thanks in advance.
/*Javascript Function for onsubmit*/
function addVersion()
alert('hi');
this.VersionDynaForm.action = "./Version.do?param=add";
this.VersionDynaForm.submit();
<html:form action="/Version.do" styleId="VersionDynaForm" onsubmit= "return addVersion()">
<input type="hidden" name="actionType" value="">
<table cellspacing=0 cellpadding=2 border=0 class="table_view" id="TABLE3" >
<tr class="table_data">
<td class="smalltext" width="200px" align="left"><b>Year<span style="color:Red;">*</span></b></td>
<td width="150px">
<select id="FLP_YEAR" name="FLP_YEAR" class="mediumtext" style="width:120px; height:30px" onchange="FLP_YEARChanged()">
<option value="">Select</option>
<%
ArrayList year = new ArrayList<Version>();
year = (ArrayList)session.getAttribute("years");
if(year!=null)
for(int i=0;i<year.size();i++){
Version temp1 = (Version)year.get(i);
if(temp1.getFLP_YEAR().equals(Element6)){
%>
<OPTION selected value='<%=temp1.getFLP_YEAR()%>'><%=temp1.getFLP_YEAR()%></OPTION>
<%}
else{%>
<OPTION value='<%=temp1.getFLP_YEAR()%>'><%=temp1.getFLP_YEAR()%></OPTION>
<%}
%>
</select>
</td>
<td width="150px"></td>
<td width="200px"></td>
<td width="200px"></td>
<td width="150px"></td>
<td width="150px"></td>
<td width="200px"></td>
</tr>
<tr class="table_data">
<td class="smalltext" width="200px" align="left"><b>Business Line<span style="color:Red;">*</span></b></td>
<td widht="150px">
<select id="LPA_BUSINESS_LINES" name="LPA_BUSINESS_LINES" class="mediumtext" style="width:120px; height:30px" onchange="alert('hi');testChanged()">
<option value="">Select</option>
<%
ArrayList lst1 = new ArrayList<Version>();
lst1 = (ArrayList)session.getAttribute("mnemonic1");
if(lst1!=null)
for(int i=0;i<lst1.size();i++){
Version temp1 = (Version)lst1.get(i);
if(temp1.getLPA_BUSINESS_LINES().equals(Element1)){
%>
<OPTION selected value='<%=temp1.getLPA_BUSINESS_LINES()%>'> <%=temp1.getLPA_BUSINESS_LINES()%></OPTION>
<%}
else{%>
<OPTION value='<%=temp1.getLPA_BUSINESS_LINES()%>'> <%=temp1.getLPA_BUSINESS_LINES()%></OPTION>
<%}
%>
</select>
</td>
<td width="150px"></td>
<td width="200px"></td>
<td width="200px"></td>
<td width="150px"></td>
<td width="150px"></td>
<td width="200px"></td>
</tr>
<tr class="table_data" align="left">
<td class="smalltext" width="200px" align="left"><b>RC Number<span style="color:Red;">*</span></b></td>
<td width="150px">
<select id="LPA_RC_NUMBER" name="LPA_RC_NUMBER" class="mediumtext" style="width:120px; height:30px" onchange="LPA_RC_NUMBERChanged()">
<option value="">Select</option>
<%
ArrayList lst2 = new ArrayList<Version>();
lst2 = (ArrayList)session.getAttribute("rcmnemonic");
if(lst2!=null && Element2!=null)
for(int i=0;i<lst2.size();i++){
Version temp2 = (Version)lst2.get(i);
if(temp2.getLPA_RC_NUMBER().equals(Element2)){
%>
<OPTION selected value='<%=temp2.getLPA_RC_NUMBER()%>'> <%=temp2.getLPA_RC_NUMBER()%></OPTION>
<%}
else{%>
<OPTION value='<%=temp2.getLPA_RC_NUMBER()%>'> <%=temp2.getLPA_RC_NUMBER()%></OPTION>
<%}
%>
</select>
</td>
<td class="smalltext" width="200px" align="left"><b>Version<span style="color:Red;">*</span></b></td>
<td width="150px">
<select id="LPA_VERSION_ID" name="LPA_VERSION_ID" class="mediumtext" style="width:120px; height:30px" onchange="LPA_VERSION_IDChanged()">
<option value="">Select</option>
<%
ArrayList ver = new ArrayList<Version>();
ver = (ArrayList)session.getAttribute("version");
if(ver!=null && Element5!=null)
for(int i=0;i<ver.size();i++){
Version temp3 = (Version)ver.get(i);
if(temp3.getLPA_VERSION_ID().equals(Element5)){
%>
<OPTION selected value='<%=temp3.getLPA_VERSION_ID()%>'> <%=temp3.getLPA_VERSION_NO()%></OPTION>
<%}
else{%>
<OPTION value='<%=temp3.getLPA_VERSION_ID()%>'> <%=temp3.getLPA_VERSION_NO()%></OPTION>
<%}
%>
</select>
</td>
<td width="150px"></td>
<td width="200px"></td>
<td width="200px"></td>
<td width="150px"></td>
</tr>
<tr class="table_data" >
<td class="smalltext" width="200px" align="left"><b>Project<span style="color:Red;">*</span></b></td>
<td width="150px">
<select id="LPA_PROJECT_NAME" name="LPA_PROJECT_NAME" class="mediumtext" style="width:120px; height:30px" onchange="LPA_PROJECT_NAMEChanged()">
<option value="">Select</option>
<%
ArrayList lst3 = new ArrayList<Version>();
lst3 = (ArrayList)session.getAttribute("project");
if(lst3!=null && Element3!=null)
for(int i=0;i<lst3.size();i++){
Version temp2 = (Version)lst3.get(i);
if(temp2.getLPA_PROJECT_NAME().equals(Element3)){
%>
<OPTION selected value='<%=temp2.getLPA_PROJECT_NAME()%>'> <%=temp2.getLPA_PROJECT_NAME()%></OPTION>
<%}
else{%>
<OPTION value='<%=temp2.getLPA_PROJECT_NAME()%>'> <%=temp2.getLPA_PROJECT_NAME()%></OPTION>
<%}
%>
</select>
</td>
<td align="left" class="smalltext" width="150px"><b>Version Name</b><span style="color:Red;">*</span></td>
<td><input type="text" class="smalltext" property="LPA_VERSION_NAME" name="LPA_VERSION_NAME" value="" maxlength="30"/></td>
<td width="150px"></td>
<td width="200px"></td>
<td width="200px"></td>
<td width="200px"></td>
</tr>
</table>
<table cellspacing=0 cellpadding=2 border=0 class="table_input" id="TABLE2" >
<tr class="table_input">
<td height="10px" colspan="5" class="table_top_td" align = "right" >
<INPUT id="button" class="mediumtext" style="width:80px; height:20px;" type="submit" value="NewVersion" class="btn" >
<INPUT id="button" class="mediumtext" style="width:80px; height:20px;" type="button" value="Update" class="btn" name="method" onclick="javascript:return updateFunction();">
<INPUT id="button" class="mediumtext" style="width:80px; height:20px;" type="button" value=Cancel class="btn" name="method" onclick="history.go(-1)" >
</td>
</tr>
</table>
hi
change the type="button" in the following line
<INPUT id="button" class="mediumtext" style="width:80px; height:20px;" type="submit" value="NewVersion" class="btn" >
and call the javascript function on onClick in above line and dont call it from form(tat u hav done), remove it from form
then it wont submit twice
-venkat
Similar Messages
-
I have a simple web page with two form elements say, two text box and submit button. when submitting my form, i didn't get the form data in my action page. This occurs only in Firefox 3.6.13 several times. Not always.
May be form get submitted twice?
Note: Remember, i am not facing this issue. However my friend is facing this issue.I have a simple web page with two form elements say, two text box and submit button. when submitting my form, i didn't get the form data in my action page. This occurs only in Firefox 3.6.13 several times. Not always.
May be form get submitted twice?
Note: Remember, i am not facing this issue. However my friend is facing this issue. -
History problem in jsp page,internet explorer back button
hi everyone
i have a jsp page suppose a.jsp.in which i am using dropdown menu to displays:list of data from database,one submit button i am using name select and click here.after selecting the value from dropdown menu ,again some other data will be displayed from some other table in same a.jsp page.
my problem is:
when user selects one value from drop down menu ,it is diplaying the value in same page .upto here is ok
and i click back button from I.E only one page back it is showing
but when user select the value form drop down menu 2nd time ,and after data get dipalyed in same apge a.jsp.then
whne i click back button ,now it is showing two a.jsp page .history is not going .
this is the problem.i dont want to this morw than one page get displayed in back button.only one page a.jsp
if anyone has understood my problem ,please help.
thankuthanks java2006
but it is not working .i will try to explain once again
1. one page called a.jsp.this page contains one drop drown menu list box ,and one submit button.
2.data in drop dropdown is coming from db.as the user select value from drop down box .relalted value is diplayed on same a.jsp page.
3.again user select the 2ndvalue from drop down box ,related value is displayed.
this i explained about my a.jsp page.
problem is
4.when user select the 1st value and clcik on submit button related value is displaying.upto here its ok.and in back button of Internet explorer it is showing only one a.jsp page
5.but whenever i am trying to see 2nd or 3rd or more value from drop down after related value is being diplayed in same a.jsp page.
the back button of internet exlorer showing two a.jsp page after clcicking submit button
.as u have told the code aso but it is not working
i have added ur code indisde html tags . -
How to submit two forms once in one jsp page?
hello all,
My jsp page includes two forms: one form's action is a File Upload servlet, which process file uploading; another is a general servlet to collect user inputs, such as user name, age, etc.
Because the file upload servlet is a legacy component, and it was used in many applications. we could not meger it into our business components.
the system requires the file upload and information collection are submitted once. so we have to submit two forms in one 'Submit' action, at the same time, the information collection servlet need get the information from file upload servlet, such as the uploaded file's url.
I have tried two methods, but all failed
1. Upload form has no a 'Submit' button, when user click the 'submit' button of the information collection form, we use a javascript to submit upload form first, then submit information collection form. Failed at: the second submit dose wait for upload finishing, then the second submit interrupt the upload
2. the javascript only submit upload form, and set HTML body's onUnload event to another javascript that submit information collection form. this time, the file upload sucess, and information collection form sucess at most time. But fail when user click the 'refresh' or 'back' or any navigator buttons of the browser. these action will trigger the page 'unload' event too, but the submit if invalid!
Please tell me how to.chain the both requests!
- build one mutlitpart request and send it to a servlet that can handle that multipart request (think of using oreilly MultiPartParser).
- check the input (all requiered fields and files there)
- if yes store the user fields and create a socket connection from your servlet to the legacy file upload servlet and post the file this way.
- like this you have full control over the users input and can make sure the file and the fields are just save if all requiered elements are availble. -
HELP!!!!!!!!! 3 Submit Buttons on 1 JSP page
Hi,
I would really appreciate any assistance to my question. I have 3 submit buttons that need to be passed to another JSP page.
1. Is it possible to use submit 3 times like here?
<input type="submit" name="btnSub" value="Modify">
<input type="submit" name="btnSub" value="Remove">
<input type="submit" name="btnSub" value="Pssword Reset">
2. Below is my code. Can you show me how to pass the values from the 3 submit buttons?
Thanks in Advance!
</form>
</td>
<td width=212 style='width:159.0pt;background:#FFE599;padding:0in 0in 0in 0in'>
<!-- Profile Maintenance ------------------------------------------------------------------------->
<div align=center>
<table border=2 cellpadding=0 style='mso-cellspacing:1.5pt;mso-padding-alt:
0in 0in 0in 0in'>
<form NAME="queryUserName" method="GET" ENCTYPE="application/x-www-form=urlencoded"
action="securityProfile.jsp"> <!-- onSubmit = "return checkForm();"-->
<tr>
<td colspan=2 style='padding:0in 0in 0in 0in'>
<p class=MsoNormal align=center style='text-align:center'><b><span
style='font-size:10.0pt;font-family:Geneva;color:#990000'> Profile Maintenance </span></b> </p>
</td>
</tr>
<tr>
<td align=center colspan=2 style='padding:0in 0in 0in 0in'>
<select name="UserID" size="5">
<option selected value="NO_VALUE"> --Select an Admin-- </option>
<% while(rset.next())
v_ID = rset.getString("ID");
v_Name = rset.getString("Name");
%>
<option value="<%= v_ID %>"><%= v_Name%></option>
<% System.out.println("List of Options counter: *** " + i + " ***"); %>
<!-- <option value="<%= i %>" > <%= v_Name%> </option> -->
<%
i = i + 1;
%>
</select></font></td>
</td>
</tr>
<tr>
<td align="center" style='padding:0in 0in 0in 0in'>
<p class=MsoNormal><span style='font-size:7.5pt;font-family:Geneva;
color:#990000'> To modify admin's access to Corp Functions, Business Units, & Dept IDs: </span><br>
<input type="submit" name="btnSub" value="Modify Profile"> </p>
</td>
</tr>
<tr>
<td align="center" style='padding:0in 0in 0in 0in'>
<p class=MsoNormal><span style='font-size:7.5pt;font-family:Geneva;
color:#990000'> To remove an admin: </span><br>
<input type="submit" name="btnSub" value="Remove Admin"> </p>
</td>
</tr>
<tr>
<td align="center" style='padding:0in 0in 0in 0in'>
<p class=MsoNormal><span style='font-size:7.5pt;font-family:Geneva;
color:#990000'> To change admin's password: </span><br>
<input type="submit" name="btnSub" value="Password Reset"> </p>
</td>
</tr>
</form>When implementing the code below, it only reads the first form, and then stops there. It doesn't execute the 2nd form.
<form name='form_1' action='T2.jsp'>
<input type=hidden name="user" value="Me">
<input type=submit value='Button1'>
<form name='form_2' action='T3.jsp'>
<input type=submit value='Button2'>
</form>
</form>
If I put each form separtely like below, then it returns nothing.
<form name='form_1' action='T2.jsp'>
<input type=hidden name="user" value="Me">
<input type=submit value='Button1'>
</FORM>
<form name='form_2' action='T3.jsp'>
<input type=submit value='Button2'>
</FORM>
What's my other alternative? I would appreciate any help. -
How to save your position in a JSP page on submit
I am building a web application based on JSP pages and servlets. One of the JSP pages is larger than the screen, so i have to scroll down. On the lower part of the page, i have a control that submits a form to a servlet that performs some logic and then returns to the same JSP page. When the JSP page is redisplayed, it is positioned at its top position again. I would like to save my positioning on the page and return to the exact same scroll position. How is this easiest done?
Just use an onclick or onsubmit event to get the current scroll position using JS and send it along the request to the server side and let it set the value in an onload event of the page which comes with the response.
I am not going to give you JS+DOM codes here. Just learn it and if necessary ask help at the appropriate forum. There are JS and DOM tutorials at w3schools.com and there are clientside development forums at webdeveloper.com and dynamicdrive.com. -
Generating XML on Submit of JSP Page
Dear all,
We need to code JSP pages which will generate the XML Request document dynamically after user submits the form.
Can anybody tell, how to go about doing this?
Thanks & Regards
Seemathe general idea is to get the data after the submit and call a java class, that you have to code, wich will generate an xml doc with the submitted data.
for more details about how to code an xml java class take a glance at this
http://forum.java.sun.com/thread.jsp?forum=34&thread=416365
hope this will help! -
Submit the jsp page containing the textarea
Hi,
I have a jsp page containing the textarea and a submit button. This page is submitted using POST. In the next page the content of the textarea is obtained and displayed. Can anyone let me know if there is any maximum limit on the characters in the textarea?
I am using JRUN3.1.
If the characters in the textarea is increasing 2000 characters, in the next page if i try to get the content of the textarea i am getting as null???
please help me out.Hi,
There is a limit as to how much data that can be passed using the GET method. Dont remember it at the top of my head now.
It would be better to use the POST method.
Sandesh -
Button action with onclick in a jsp page using Jscript
hi,
I am facing a problem in setting an action with a button in a jsp page the error is object does'nt support this function,kindly send me reply as soon as possible.
Santhoshhi,
I am facing a problem in setting an action with a button in a jsp page the error is object does'nt support this function,kindly send me reply as soon as possible.
Santhosh -
In JSP pages request.getParameter returns null
There are two jsp's,the first JSP has 1 textbox inside the form tag.We input the values in the textbox and submit.
Code :Ist jsp
<BODY>
<HEAD>
function validate()
document.add.submit();
</HEAD>
<FORM name="add" method="post" action=/dir/two.jsp" >
<TABLE width="37%" border="0" align="center" class="c4f3">
<TR>
<TD class="c4">Rating</TD>
<TD><input type=text name="rating"></TD?
</TR>
<TR>
<TD align=center><INPUT type="button" name="submitadd" value="Submit" onClick="validate()" </TD>
</TR>
</TABLE>
</FORM>
</BODY>
After the submit it goes to the 2nd JSP page .
code:2nd Jsp
<%
String Rating=request.getParameter("rating");
out.println(" Rating "+Rating);
%>
The 2nd JSP pages gets the values by request.getParameter.When I use method='post' in Ist JSP ,even if I enter values in the textbox, it prints null. But when I give method="get" , it prints the value.
Pls let me know if there is any problem in the code or its the problem due to webserver configuration.Also suggest the solution to over come this problem.
ThanksIf I'am right you have misplaced the opening body-tag of your first jsp-page.
The opening body-tag should follow after the closing head tag .
The structure of your HTML-code should look like this:
<html>
<head>
</head>
<body>
</body>
</html> -
My JSP page takes a lot of time to go to next JSP
Hi All,
I have a JSP page which loads dynamically depending on what the user enters. This page works fine for items upto 20-30 but as the number of items increases, my JSP page takes a lot of time to go to the next one. Heres what my JSP looks like:
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-form.tld" prefix="form" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/rswtags.tld" prefix="rsw" %>
<jsp:useBean id="dateFormatIntl" scope="session" type="java.lang.String"/>
<html>
<head>
<title><bean:message key="title.application"/> - <bean:message key='header.return_to_vendor_detail'/></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%@ include file="rsw_functions.jsp" %>
<%@ include file="shipment_rtv_functions.jsp" %>
<script language="JavaScript" type="text/javascript">
var page = "<bean:message key='header.return_to_vendor_detail'/>"
var rtvEntryArray = new Array();
var totalAmtString;
function setFormValues()
var rtvEntriesString = "";
for (var v = 0; v < rtvEntryArray.length; v++)
var rtvEntryString = rtvEntryArray[v].itemNumber + "~"
+ rtvEntryArray[v].itemQty + "~"
<rsw:display displayElementName="rtv_reason">
+ rtvEntryArray[v].inventoryStatusCode + "~"
+ rtvEntryArray[v].inventoryStatusName + "~"
+ rtvEntryArray[v].reasonCodeId + "~"
+ rtvEntryArray[v].reasonCodeName + "~" +
</rsw:display>
<rsw:display_false displayElementName="rtv_reason">
+ " " + "~"
+ " " + "~"
+ " " + "~"
+ " " + "~" +
</rsw:display_false>
rtvEntryArray[v].valid;
rtvEntriesString = rtvEntriesString + rtvEntryString + ";";
document.rtvVsatShipmentForm.rtvEntriesString.value = rtvEntriesString;
function writeItem(itemNumber, itemQty, inventoryStatusCode, inventoryStatusName,
reasonCodeId, reasonCodeName)
if(!acquireFakeLock()) return;
if (!arrayContainsItem(itemNumber, reasonCodeId))
addEntry(itemNumber, itemQty, inventoryStatusCode, inventoryStatusName,
reasonCodeId, reasonCodeName, "true");
else
setItemQtyReasonArray(itemNumber, itemQty, reasonCodeId, reasonCodeName);
writeTable(false);
releaseFakeLock();
function handleApply()
<%-- change this if 'please select...' value changes to something other than a space --%>
if (document.rtvVsatShipmentForm.applyReasonCode.value == " ")
alert('<bean:message key="error.must_enter_a_reason" />');
return;
if (checkQuantityGreaterThenZero(document.rtvVsatShipmentForm.applyQty))
formatQuantity(document.rtvVsatShipmentForm.applyQty);
if (document.rtvVsatShipmentForm.applyId.value == '')
alert("<bean:message key='error.no_dsd_order_entries' />");
document.rtvVsatShipmentForm.applyId.focus();
return;
writeItem(document.rtvVsatShipmentForm.applyId.value,
document.rtvVsatShipmentForm.applyQty.value
<rsw:display displayElementName="rtv_reason">,
document.rtvVsatShipmentForm.selectedInventoryStatus.options[document.rtvVsatShipmentForm.selectedInventoryStatus.selectedIndex].value,
document.rtvVsatShipmentForm.selectedInventoryStatus.options[document.rtvVsatShipmentForm.selectedInventoryStatus.selectedIndex].text,
document.rtvVsatShipmentForm.applyReasonCode.options[document.rtvVsatShipmentForm.applyReasonCode.selectedIndex].value,
document.rtvVsatShipmentForm.applyReasonCode.options[document.rtvVsatShipmentForm.applyReasonCode.selectedIndex].text
</rsw:display>
document.rtvVsatShipmentForm.applyId.value = '';
document.rtvVsatShipmentForm.applyQty.value = 1;
document.rtvVsatShipmentForm.applyId.focus();
<rsw:display displayElementName="rtv_reason">
document.rtvVsatShipmentForm.selectedInventoryStatus.value
= document.rtvVsatShipmentForm.selectedInventoryStatus.options[0].value;
selectFromInvStatus();
</rsw:display>
totalAmounts();
function clearFields()
document.rtvVsatShipmentForm.returnAuth.value = "";
document.rtvVsatShipmentForm.applyId.value = "";
document.rtvVsatShipmentForm.applyQty.value = "1";
document.rtvVsatShipmentForm.applyId.focus();
document.rtvVsatShipmentForm.selectedInventoryStatus.value = document.rtvVsatShipmentForm.selectedInventoryStatus.options[0].value;
selectFromInvStatus();
function getCurrentOptions()
if (document.rtvVsatShipmentForm.selectedInventoryStatus.value == "AVAILABLE")
return availableOptions;
return unavailableOptions;
function populateDropDown(dropdownField)
var currentOptions;
currentOptions = getCurrentOptions();
dropdownField.options.length = 0;
var oPleaseSelectOption = document.createElement("OPTION");
oPleaseSelectOption.value = " ";
oPleaseSelectOption.text = "<bean:message key="label.please_select"/>";
dropdownField.options.add(oPleaseSelectOption);
for (var i = 0; i < currentOptions.length; i++)
dropdownField.options.add(currentOptions);
function selectFromInvStatus()
populateDropDown(document.rtvVsatShipmentForm.applyReasonCode);
function initialize()
document.rtvVsatShipmentForm.applyId.focus();
createReasonOptionObjects();
selectFromInvStatus();
<logic:equal name="rtvVsatShipmentForm" property="returnAuthRequired" value="true">
if (document.rtvVsatShipmentForm.returnAuth.value == '')
document.rtvVsatShipmentForm.returnAuth.focus();
</logic:equal>
createEntryArray(document.rtvVsatShipmentForm.rtvEntriesString.value, false);
<rsw:display displayElementName="rtv_reason">
</rsw:display>
totalAmounts();
function next()
setFormValues();
if (document.rtvVsatShipmentForm.rtvEntriesString.value == '')
alert("<bean:message key='error.no_dsd_order_entries' />");
document.rtvVsatShipmentForm.applyId.focus();
return;
<logic:equal name="rtvVsatShipmentForm" property="returnAuthRequired" value="true">
if (document.rtvVsatShipmentForm.returnAuth.value == '')
alert("<bean:message key='error.return_auth_required' />");
document.rtvVsatShipmentForm.returnAuth.focus();
return;
</logic:equal>
if (!validateTextAreaLength(document.rtvVsatShipmentForm.comments,
"<bean:message key='label.comments'/>", 255))
return false;
document.rtvVsatShipmentForm.submit();
function doBack()
backLink.href = "<bean:write name='rtvVsatShipmentForm' property='previousAction' />";
document.rtvVsatShipmentForm.action=backLink.href;
document.rtvVsatShipmentForm.submit();
function handleItemLookup()
window.open(itemLookupLink.href + "?actionToReturnTo=shipment_rtv_vsat_create&fieldToPopulateUponReturn=applyId","RSWLookupWindow");
</script>
<jsp:include page="/elements/top_banner2.jsp" flush="true"/>
<!-- Beginning of Page Body -->
<body onload="initialize();displayErrors();">
<form:form action="shipment_rtv_vsat_to_summary.do" style="margin-top:0">
<input type="hidden" name="fieldToPopulateUponReturn" value="applyId">
<span style="display:none">
<html:link styleId="itemLookupLink" href="item_lookup_start.do"></html:link>
<html:link styleId="backLink" href="dummyLink"></html:link>
</span>
<html:hidden property="rtvEntriesString"/>
<form:hidden property="fromLocationId" />
<table width="700" class="bgColor" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="spacerCell">
</td>
</tr>
<tr>
<td class="leadSpacerCell" rowspan="3"></td>
<td class="bodymd" width="125">
<bean:message key="label.rtv_number" />:
</td>
<td class="bodymd">
<bean:write name="rtvVsatShipmentForm" property="rtvNumber" />
</td>
<td class="bodymd">
</td>
<td class="bodymd">
<bean:message key= "label.date" />:
</td>
<td class="bodymd" align="left">
<bean:write name="rtvVsatShipmentForm" property="createDate"/>
</tr>
<tr>
<td class="spacerCell">
</td>
<td colspan="3"></td>
<logic:equal name="dateFormatIntl" value="true">
<td align="left" valign="top" class="bodymd">
<span class="bodyxsm">(<bean:message key="label.date_format_string_intl"/>)</span>
</td>
</logic:equal>
<logic:notEqual name="dateFormatIntl" value="true">
<td>
<span class="bodyxsm">(<bean:message key="label.date_format_string_us"/>)</span>
</td>
</logic:notEqual>
</tr>
<tr>
<td class="bodymd">
<bean:message key="label.status" />:
<td class="bodymd">
<rsw:display displayElementName="rtv_status">
<form:select property="selectedStatusCode" >
<form:options name="rtvVsatShipmentForm" property="statusIds"
labelProperty="statusNames" />
</form:select>
</rsw:display>
<rsw:display_false displayElementName="rtv_status">
<bean:write name="rtvNonVsatShipmentForm" property="selectedStatus.description" />
</rsw:display_false>
</td>
</td>
</tr>
<tr>
<td class="spacerCell">
</td>
</tr>
<tr>
<td class="leadSpacerCell"></td>
<td class="bodymd">
<bean:message key="label.ship_from_location" />:
</td>
<td class="bodymd" colspan="5">
<bean:write name="rtvVsatShipmentForm" property="fromLocationId" />
</td>
</tr>
<tr>
<td class="spacerCell">
</td>
</tr>
<tr>
<td class="leadSpacerCell">
<td class="bodymd">
<bean:message key="label.supplier_name" />:
</td>
<td class="bodymd">
<bean:write name="rtvVsatShipmentForm" property="supplierName" />
</td>
<td class="bodymd" width="125">
<bean:message key="label.supplier_number" />:
</td>
<td class="bodymd" colspan="3">
<bean:write name="rtvVsatShipmentForm" property="supplierId" />
</td>
</tr>
<tr>
<td class="spacerCell">
</td>
</tr>
<tr>
<td class="leadSpacerCell">
<td class="bodymd">
<bean:message key="label.rtv_paid" />:
</td>
<td class="bodymd" align="left">
<form:select property="selectedPaymentStatusCode" >
<form:options name="rtvVsatShipmentForm" property="paymentStatusIds"
labelProperty="paymentStatusNames" />
</form:select>
</td>
<td class="leadSpacerCell">
</td>
</tr>
<%-- <tr>
<td class="bodymd">
<bean:message key="label.check_number" />:
</td>
<td class="bodymd" align="left">
<form:text name="rtvVsatShipmentForm" property="checkNumber" maxlength="12"/>
</td>
</tr>
--%>
</table>
<table width="700" class="bgColor" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="spacerCell">
</td>
<tr>
<td class="leadSpacerCell">
</td>
<td colspan="3">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="bodymd">
<bean:message key="label.return_authorization_no" />:
</td>
<td class="bodymd" align="left">
<form:text name="rtvVsatShipmentForm" property="returnAuth" maxlength="12"/>
</td>
<td class="leadSpacerCell">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="spacerCell">
</td>
</tr>
<tr>
<td class="leadSpacerCell">
</td>
<td class="bodymd" valign="top">
<bean:message key="label.supplier_address" />
</td>
</tr>
<tr>
<td class="leadSpacerCell">
</td>
<td colspan="6">
<table border="0">
<tr>
<td width="10" rowspan="4">
</td>
<td class="bodymd">
<form:text property="addressLine1" style="width:200" />
</td>
<td width="5">
</td>
<td class="bodymd">
<bean:message key="label.city" />:
</td>
<td colspan="3" class="bodymd">
<form:text property="addressCity" style="width:200" />
</td>
</tr>
<tr>
<td class="bodymd">
<form:text property="addressLine2" style="width:200" />
</td>
<td width="5">
</td>
<td class="bodymd">
<bean:message key="label.state_or_province" />:
</td>
<td class="bodymd">
<form:text property="addressStateOrProvince" style="width:80" />
</td>
<td class="bodymd">
<bean:message key="label.postal_code" />:
</td>
<td class="bodymd">
<form:text property="addressPostalCode" style="width:80" />
</td>
</tr>
<tr>
<td class="bodymd">
<form:text property="addressLine3" style="width:200" />
</td>
<td width="5">
</td>
<td class="bodymd">
<bean:message key="label.country" />:
</td>
<td colspan="3" class="bodymd">
<form:text property="addressCountry" style="width:200" />
</td>
</tr>
</table>
</td>
<tr>
<td class="spacerCell">
</td>
</tr>
<tr>
<td class="spacerCell">
</td>
</tr>
<tr>
<td class="leadSpacerCell">
</td>
<td class="bodymd" valign="top">
<bean:message key="label.comments" />:
</td>
<td>
<form:textarea property="comments" cols="65" rows="3" onkeypress="limitKeyPress(this, 255)"/>
</td>
</tr>
<tr>
<td class="spacerCell">
</td>
</tr>
<tr>
<td colspan="3" class="horizontalLine">
</td>
</tr>
<tr>
<td class="spacerCell">
</td>
</tr>
</table>
<table width="700" cellpadding="0" cellspacing="0" border="0" class="bgColor">
<tr>
<td class="leadSpacerCell"></td>
<td class="bodymdbold"><bean:message key='label.item'/>: </td>
<td><form:text size="15" property="applyId"/> </td>
<td class="bodymdbold"><bean:message key='label.quantity'/>: </td>
<td><form:text size="8" maxlength="8" property="applyQty" /> </td>
<rsw:display displayElementName="rtv_reason">
<td style="display:none" class="bodymdbold"><bean:message key='label.inventory_status'/>: </td>
<td style="display:none">
<form:select property="selectedInventoryStatus" onchange="selectFromInvStatus();">
<form:options name="rtvVsatShipmentForm" property="inventoryStatusCodes"
labelProperty="inventoryStatusDescriptions" />
</form:select>
</td>
<td class="bodymdbold"><bean:message key='label.reason_code'/>: </td>
<td>
<select name="applyReasonCode">
<%-- <logic:iterate name="rtvVsatShipmentForm" property="rtvReasons" id="reason">
<option value="<bean:write name="reason" property="code"/>">
<bean:write name="reason" property="description"/>
</option>
</logic:iterate>
--%>
</select>
</td>
</rsw:display>
</tr>
<tr>
<td class="leadSpacerCell"></td>
<td class=bodymd>
<a class="genericLink" href="" onClick="handleItemLookup(); return false"><bean:message key='link.item'/></a>
</td>
</tr>
<tr>
<td class="leadSpacerCell"></td>
<td colspan="9" align="left">
<br>
<input type="submit"
value="<bean:message key='button.apply'/>"
onClick="handleApply();return false;">
<input type="button" value="Clear" onclick="clearFields()";></td>
</tr>
<tr>
<td class="spacerCell">
</td>
</tr>
<tr>
<td class="horizontalWhiteLine" colspan="10"></td>
</tr>
</table>
<table class="bgColor" width="700" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="spacerCell">
</td>
</tr>
<tr>
<td><rsw:errors/></td>
</tr>
</table>
<div id="item_list_div">
</div>
<table width="700" cellpadding="0" cellspacing="0" border="0" class="bgColor">
<tr>
<td class="spacerCell"></td>
</tr>
<tr>
<td>
<table width="700" cellpadding="0" cellspacing="0" border="0" class="bgColor">
<tr>
<td class="bodymdbold" align="right" nowrap><div id="total_amt_div"></div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="spacerCell"></td>
</tr>
<tr>
<td class="horizontalLine" colspan="3"></td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" border="0" width="700">
<tr>
<td class="spacerCell"></td>
</tr>
<tr>
<td class="leadSpacerCell">
</td>
<td align="left">
<input type="button" value="<bean:message key='button.next'/>"
onclick="next();">
<input type=button value="<bean:message key='button.back'/>"
onclick="doBack();">
<input type=button value="<bean:message key='button.cancel'/>"
onclick="doSubmit('main', 'main.do');">
</td>
</tr>
</table>
</form:form>
<div id="log"></div>
</body>
<!-- End of Page Body -->
<jsp:include page="/elements/bottom_banner2.jsp" flush="true"/>
<script language="JavaScript" type="text/javascript">
function handleAction(retVal,position)
if (retVal != null)
var command = retVal["command"];
if (command == "OK")
updateArray(retVal["id"],
formatQuantityFromVar(retVal["qty"]), true,
<rsw:display displayElementName="rtv_reason">
retVal["inventoryStatusCode"],
retVal["inventoryStatusName"],
retVal["reasonCode"],
retVal["reasonDescription"],
</rsw:display>
<rsw:display_false displayElementName="rtv_reason">
null, null, null, null,
</rsw:display_false>
position);
totalAmounts();
if (command == "Remove")
deleteRow(position);
writeTable(false);
totalAmounts();
function showEditWindow(sku, qty,
<rsw:display displayElementName="rtv_reason">
inventoryStatusCode, reasonCode,
</rsw:display>
position)
if(!acquireFakeLock()) return;
var elements = editWindowDiv.document.all;
elements("editWindowId").value=sku;
elements("editWindowQty").value = qty;
<rsw:display displayElementName="rtv_reason">
elements("editWindowInventoryStatusCode").value = inventoryStatusCode;
elements("hiddenReasonCode").value = reasonCode;
</rsw:display>
var retVal;
// if (IE6)
retVal = window.showModalDialog("popup.jsp", editWindowDiv,
"dialogWidth:335px;dialogHeight:230px;scroll:no;status:no;unadorned:no");
else
retVal = window.showModalDialog("javascript:document.write(window.dialogArguments.innerHTML);editWindowInit();",editWindowDiv,
"dialogWidth:335px;dialogHeight:230px;scroll:no;status:no;unadorned:no");
handleAction(retVal,position);
releaseFakeLock();
function updateArray(itemNumber, itemQty, fromEditWindow,
inventoryStatusCode, inventoryStatusName,
reasonCodeId, reasonCodeName, position, supplierCost)
if (((rtvEntryArray[position].reasonCodeId != reasonCodeId)
&& arrayContainsItem(itemNumber, reasonCodeId))
||
((rtvEntryArray[position].itemNumber != itemNumber)
&& arrayContainsItemsExceptPos(itemNumber, reasonCodeId, position)))
deleteRow(position);
setItemQtyReasonArray(itemNumber, itemQty, reasonCodeId, reasonCodeName, supplierCost);
else
var rtvEntry = new Object();
rtvEntry.itemNumber = itemNumber;
rtvEntry.itemQty = itemQty;
rtvEntry.inventoryStatusCode = inventoryStatusCode;
rtvEntry.inventoryStatusName = inventoryStatusName;
rtvEntry.reasonCodeId = reasonCodeId;
rtvEntry.reasonCodeName = reasonCodeName;
rtvEntry.supplierCost = supplierCost;
rtvEntry.valid = rtvEntryArray[position].valid;
rtvEntryArray[position] = rtvEntry;
writeTable();
</script>
<div id="editWindowDiv" style="display:none">
<html>
<head>
<style type="text/css">
.titleTxt { font-size: 12 ; font-style: italic ; font-weight: bold; color: white ; font-family: arial }
.bodymd {color: #000000; font-family: arial; font-size: 10pt; text-decoration: none}
.bodymdbold {color: #000000; font-family: arial; font-size: 10pt; text-decoration: none; font-weight: bold}
.bgColor { background-color: #efefef }
</style>
<title><bean:message key="title.edit_window" /></title>
<script language="JavaScript">
function handleOk()
if (checkQuantityGreaterThenZero(document.editPopupForm.editWindowQty))
var returnArray = new Array();
returnArray["id"] = document.editPopupForm.editWindowId.value;
returnArray["qty"] = document.editPopupForm.editWindowQty.value;
<rsw:display displayElementName="rtv_reason">
returnArray["inventoryStatusCode"] = document.editPopupForm.editWindowInventoryStatusCode.options[document.editPopupForm.editWindowInventoryStatusCode.selectedIndex].value;
returnArray["inventoryStatusName"] = document.editPopupForm.editWindowInventoryStatusCode.options[document.editPopupForm.editWindowInventoryStatusCode.selectedIndex].text;
returnArray["reasonCode"] = document.editPopupForm.editWindowReasonCode.options[document.editPopupForm.editWindowReasonCode.selectedIndex].value;
returnArray["reasonDescription"] = document.editPopupForm.editWindowReasonCode.options[document.editPopupForm.editWindowReasonCode.selectedIndex].text;
</rsw:display>
returnArray["command"] = "OK";
window.returnValue = returnArray;
window.close();
function handleCancel()
window.close();
function handleRemove()
var returnArray = new Array();
returnArray["command"] = "Remove";
window.returnValue = returnArray;
window.close();
function init()
document.title = "<bean:message key="title.edit_window" />";
document.editPopupForm.editWindowQty.focus();
<rsw:display displayElementName="rtv_reason">
createReasonOptionObjects();
setReasonOptions();
document.editPopupForm.editWindowReasonCode.value = document.editPopupForm.hiddenReasonCode.value;
</rsw:display>
<rsw:display displayElementName="rtv_reason">
function setReasonOptions()
var currentOptions;
document.editPopupForm.editWindowReasonCode.options.length = 0;
if (document.editPopupForm.editWindowInventoryStatusCode.value == "AVAILABLE")
currentOptions = availableOptions;
else
currentOptions = unavailableOptions;
for (var i = 0; i < currentOptions.length; i++)
document.editPopupForm.editWindowReasonCode.options.add(currentOptions[i]);
</rsw:display>
var availableOptions = new Array();
var unavailableOptions = new Array();
<rsw:display displayElementName="rtv_reason">
function createReasonOptionObjects()
var oOption;
<logic:iterate name="rtvVsatShipmentForm" property="availableInventoryStatusReasons" id="reason">
oOption = document.createElement("OPTION");
oOption.value = "<bean:write name="reason" property="code"/>";
oOption.text = "<bean:write name="reason" property="description"/>";
availableOptions[availableOptions.length] = oOption;
</logic:iterate>
<logic:iterate name="rtvVsatShipmentForm" property="unavailableInventoryStatusReasons" id="reason">
oOption = document.createElement("OPTION");
oOption.value = "<bean:write name="reason" property="code"/>";
oOption.text = "<bean:write name="reason" property="description"/>";
unavailableOptions[unavailableOptions.length] = oOption;
</logic:iterate>
</rsw:display>
</script>
<%@ include file="rsw_functions.jsp" %>
</head>
<body leftmargin="0" topmargin="0" style="border:4px ridge lightgrey">
<span style="margin-top:0;margin-left:0,margin-bottom:0;margin-right:0">
<table cellspacing="0" cellpadding="0" border="0" bordercolor="#000000" width="330">
<tr>
<td bgcolor="#ff9999" width="100%" height="1" colspan="2"></td>
</tr>
<tr>
<td bgcolor="#ff0000" height="15" align="left"><span
class=titleTxt> <bean:message key="label.edit" /> </span></td>
<td bgcolor="#ff0000" height="15" align="right"><span
class="titleTxt"><bean:message key="label.application_title" /> </span></td>
</tr>
<tr>
<td bgcolor="#000000" width="100%" height="1" colspan="2"></td>
</tr>
</table>
</span>
<form name="editPopupForm" style="margin-top:0;margin-left:0,margin-bottom:0;margin-right:0"
onsubmit="handleOk();return false;">
<input type="hidden" name="editWindowPosition" value="">
<input type="hidden" name="hiddenReasonCode" value="">
<table cellspacing='0' class='bgColor' cellpadding='0' border='0' width='330'>
<tr><td> </td></tr>
<tr>
<td class='bodymd'> <bean:message key='label.item'/>:</td>
<td class='bodymd'><input type="text" name="editWindowId" value="[id]" ></td>
</tr>
<tr>
<!--Start RQST 34502 SIR 61007-->
<!--td class='bodymd'--><!-- --><!--bean:message key='label.count_quantity'/--><!--:--><!--/td-->
<td class='bodymd'> <bean:message key='label.return_quantity'/>:</td>
<!--End RQST 34502 SIR 61007-->
<td class='bodymd'><input type="text" maxlength="8" name="editWindowQty" value="[qty]"></td>
</tr>
<rsw:display displayElementName="rtv_reason">
<tr>
<td style="display:none" class='bodymd'> <bean:message key='label.inventory_status'/>:</td>
<td style="display:none" class='bodymd'><select name="editWindowInventoryStatusCode" onchange="setReasonOptions();">
<option value="AVAILABLE"><bean:message key="label.available"/></option>
<option value="UNAVAILABLE"><bean:message key="label.unavailable"/></option>
</select></td>
</tr>
<tr>
<td class='bodymd'> <bean:message key='label.reason_code'/>:</td>
<td class='bodymd'><select name="editWindowReasonCode">
<logic:iterate name="rtvVsatShipmentForm" property="rtvReasons" id="editWindowReason">
<option value="<bean:write name="editWindowReason" property="code"/>">
<bean:write name="editWindowReason"God Lord! Does anyone else here write JSPs that look like that?
If I had to maintain that I would shoot myself straight in the temple.
Sorry, I don't have answer to your question, I just had to say that.
Do you like your job? -
1.i create a database
2.then i create a jsp page for welcome
3.then another jsp page for view result
4.then i write code for java
here is my 1st jsp page
<html>
<head>
<title>login</title>
</head>
<body bgcolor=pink>
<form action="project.jsp" method=post>
Project id
 
; <input type="text" name="proj_id"><br><br>
Project Name <input
type="text" name="proj_name"><br><br>
Client Name
<input
type="text" name="client_name"><br><br>
Project Start Date <input type="text" name="strt_date"><br><br>
Est Project End Date <input type="text" name="est_date"><br><br>
Project Manager <input type="text"
name="proj_mgr"><br><br>
Est Effort
 
; <input type="text" name="est_effort"><br><br>
<input type="submit" name="add" value="Add" onClick=add() >
<input type="button" name="modify" value="Modify">
<input type="button" name="delete" value="Delete">
<input type="button" name="assign" value="Assign">
</form>
</body>
</html>
here my java page
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.io.*;
class base
PreparedStatement pstmt=null;
Connection con = null;
Statement stmt = null;
ResultSet rset = null;
int est_effort;
String proj_id,proj_name,client_name,strt_date,est_date,proj_mgr;
/* int est_effort;
String Project_id,Project_name,client_name,start_date,estimated_date,Project_mgr; */
void add( )
try
String driverName = "com.mysql.jdbc.Driver";
Class.forName(driverName);
String serverName = "192.168.10.5";
String mydatabase = "Trainees";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
String username = "josep";
String password = "josep";
con = DriverManager.getConnection(url, username, password);
System.out.println("Connected");
catch(Exception e)
System.err.println("Exception: " + e.getMessage());
try{
System.out.println("Before Update1");
pstmt=con.prepareStatement("insert into project(proj_id,proj_name,client_name,strt_date,est_date,proj_mgr,est_effort) values ('
"+Project_id+" ',' "+Project_name+"',' "+client_name+" ',' "+start_date+" ',' "+estimated_date+" ',' "+Project_mgr+" ',' "+est_effort+"')");
pstmt=con.prepareStatement("insert into project(proj_id,proj_name,client_name,strt_date,est_date,proj_mgr,est_effort) values
System.out.println("Before Update2");
pstmt.setString(1,proj_id);
pstmt.setString (2,proj_name);
pstmt.setString (3,client_name);
pstmt.setString (4,strt_date);
pstmt.setString (5,est_date);
pstmt.setString(6,proj_mgr);
pstmt.setInt(7,est_effort);
pstmt.executeUpdate();
System.out.println("" +pstmt );
catch(Exception e)
System.err.println("Exception: " + e.getMessage());
finally
try
if(con != null)
con.close();
catch(SQLException e)
void modify()
void delete()
void assign()
public class xx extends base
public static void main(String args[]) throws IOException
base a= new base();
a.add();
here my second jsp page
<%@ page language="java"%>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*"%>
<%@page import="ss.xx"%>
//<%@ page import="ss.xx.*"%>
<html>
<head><title>Welcome</title></head>
<body bgcolor = "LightGrey">
Welcome...
<br>
<%
xx obj=new xx();
obj.add( );
%>
<%
String Project_id = request.getParameter("proj_id");
String Project_name=request.getParameter("proj_name");
String client_name=request.getParameter("client_name");
String start_date=request.getParameter("strt_date");
String estimated_date=request.getParameter("est_date");
String Project_mgr=request.getParameter("proj_mgr");
int est_effort=Integer.parseInt(request.getParameter("est_effort"));
%>
<p><font size="6">Project id : <%= Project_id%></font></p>
<p><font size="6">Project Name : <%= Project_name%></font></p>
<p><font size="6">Client Name : <%= client_name%></font></p>
<p><font size="6">Project Start Date : <%= start_date%></font></p>
<p><font size="6">Est Project End Date : <%= estimated_date%></font></p>
<p><font size="6">Project Manager : <%= Project_mgr%></font></p>
<p><font size="6">Est Effort : <%= est_effort%></font></p>
</body>
</html>
here that second jsp page error
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 12 in the jsp file: /project.jsp
Generated servlet error:
The type base cannot be resolved. It is indirectly referenced from required .class files
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:409)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)Uh, those aren't runtime errors, but just compilation errors. Googling on the error message can give a lot of results.
Learn how to write Java properly. It would also help a lot if you put all the Java logic in Java classes instead of JSPs. -
HTML multipart form is not working in jsp page
Hi
i have jsp page, has a HTML from with file upload field , when i click the send button , nothing happened as if the button did not submit the form. ie the message at line 12 is not printed out.
can any one help please.
<%@ page errorPage="..\error\error.jsp" %>
<%@ page pageEncoding="windows-1256" %>
<%@ page language="java" import="javazoom.upload.*,java.util.*,java.sql.ResultSet" %>
<jsp:useBean id="upBean" scope="page" class="javazoom.upload.UploadBean" >
<jsp:setProperty name="upBean" property="folderstore" value="<%=request.getRealPath("thuraya//uploads")%>" />
</jsp:useBean>
<jsp:useBean id="dbc" class="mypackage.DBConnection" scope="session" />
<!-- add news-->
<%
if(request.getParameter("addBTN") != null){
out.println("addbtn");
//do upload file + insert in database
if (MultipartFormDataRequest.isMultipartFormData(request))
// Uses MultipartFormDataRequest to parse the HTTP request.
MultipartFormDataRequest mrequest = new MultipartFormDataRequest(request);
String todo = null;
if (mrequest != null) todo = mrequest.getParameter("todo");
if ( (todo != null) && (todo.equalsIgnoreCase("upload")) )
Hashtable files = mrequest.getFiles();
if ( (files != null) && (!files.isEmpty()) )
UploadFile file = (UploadFile) files.get("filename");
if (file != null)
out.println("<li>Form field : uploadfile"+"<BR> Uploaded file : "+file.getFileName()+" ("+file.getFileSize()+" bytes)"+"<BR> Content Type : "+file.getContentType());
String fileName=file.getFileName();
String ran=System.currentTimeMillis()+"";
String ext=fileName.substring( ( fileName.length()-4),fileName.length() );
file.setFileName(ran+ext);
// Uses the bean now to store specified by jsp:setProperty at the top.
upBean.store(mrequest, "filename");
String title=request.getParameter("title");
String content=request.getParameter("elm1");
int x=dbc.addNews(title,content,file.getFileName(),2,1);
if(x==1)
out.print("New Vedio has been addedd Successfully");
response.setHeader("Refresh","1;URL=uploadVedio.jsp");
else{
out.print("An Error Occured while adding new Vedio");
response.setHeader("Refresh","1;URL=uploadVedio.jsp");
else
out.println("<li>No uploaded files");
else out.println("<BR> todo="+todo);
%>
<!-- end of add news-->
<form action="" method="post" enctype="multipart/form-data" name="upform" >
<table width="99%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td colspan="2" align="right" bgcolor="#EAEAEA" class="borderdTable"><p>'6'A) .(1 ,/J/</p></td>
</tr>
<tr>
<td width="87%" align="right"><label>
<input name="title" type="text" class="rightText" id="title">
</label></td>
<td width="13%" align="right">9FH'F 'D.(1</td>
</tr>
<tr>
<td align="right"><textarea name="elm1" cols="50" rows="10" id="elm1" style="direction:rtl" >
</textarea></td>
<td align="right">*A'5JD 'D.(1</td>
</tr>
<tr>
<td align="right"><label>
<input type="file" name="filename" id="filename">
</label></td>
<td align="right">5H1)</td>
</tr>
<tr>
<td align="right"><label>
<input onClick="submit()" name="addBTN" type="button" class="btn" id="addBTN" value=" '6'A) .(1 ">
</label></td>
<td align="right"> </td>
</tr>
</table>
</form>
<!-- TinyMCE -->
<script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple",
directionality : "rtl"
</script>
<!--end of TinyMCE -->the problem is not because of java code insdie jsp page
I have removed all things but the form and it is still not working
here is the modified code:
<!-- add news-->
<%
if(request.getParameter("addBTN") != null){
out.print("addBTN");
%>
<!-- end of add news-->
<form action="" method="post" enctype="multipart/form-data" name="upform" >
<table width="99%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td colspan="2" align="right" bgcolor="#EAEAEA" class="borderdTable"><p>'6'A) .(1 ,/J/</p></td>
</tr>
<tr>
<td width="87%" align="right"><label>
<input name="title" type="text" class="rightText" id="title">
</label></td>
<td width="13%" align="right">9FH'F 'D.(1</td>
</tr>
<tr>
<td align="right"><textarea name="elm1" cols="50" rows="10" id="elm1" style="direction:rtl" >
</textarea></td>
<td align="right">*A'5JD 'D.(1</td>
</tr>
<tr>
<td align="right"><label>
<input type="file" name="filename" id="filename">
</label></td>
<td align="right">5H1)</td>
</tr>
<tr>
<td align="right"><label>
<input name="addBTN" type="submit" class="btn" id="addBTN" value=" '6'A) .(1 ">
</label></td>
<td align="right"> </td>
</tr>
</table>
</form>
<!-- TinyMCE -->
<script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple",
directionality : "rtl"
</script>
<!--end of TinyMCE --> -
Insert from button in jsp page
hi, im new o jso and needto make an insert frim a jsp page with a button,
what should i do?
i made a javascript function but i really dont know if am i right and then i tried to call this function from the html tag
beside this i execute de query from java and it was success!!, but i dont know what is wrong when i try from the jsp page with de button, please help!
thx!
here it's my code:
<script type="text/javascript">
import java.sql.*;
function Agregar()
return
StringBuffer sb = new StringBuffer();
try{
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/Prueba","postgres","hola");
Statement stmt = conn.createStatement();
stmt.executeUpdate("INSERT INTO tbl_responsable (cedula,nombre,direccion) VALUES (14021752,'carlos','caracas')");
}catch(Exception e){
System.out.println("EXPLOTO");
</script>
ahora en el html que debo hacer??, o si tengo q hacer otra cosa???
html del boton:
<input type="submit" value="Agregar" action="Agregar()">
what should i do, what its wrong??
thx again!try this
<input type="submit" onclick=" return Agregar();">
or
<input type="submit" onclick=" Agregar();"> -
Jsf problem go from jsp page to another jsp in new window
Ive two jsp pages attendReport.jsp and printAttendReport.jsp
attendReport.jsp contains inputs for attend duration and employee id and command button view to view attendance data entered employee during entered duration inside the same page(this work very good)
the problem is the same page includes another command button print its job is to get the same data but view them in the second page printAttendReport.jsp in another window in order to print the data in some suitable format , but the print button opens attendReport.jsp instead of printAttendReport.jsp and does not hold the inputs else if I set <managed-bean-scope> to session not request which cause caching data , please help me if you to solve this problem
and here the related lines of code
<faces-config >
<managed-bean>
<managed-bean-name>attendReportBean</managed-bean-name>
<managed-bean-class>csc.attend.bean.AttendReportBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/attend/attendReport.jsp</from-view-id>
<navigation-case>
<from-action>#{AttendReportBean.attendReport}</from-action>
<from-outcome>attendReport</from-outcome>
<to-view-id>/attend/attendReport.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/attend/attendReport.jsp</from-view-id>
<navigation-case>
<from-action>#{AttendReportBean.printAttendReportAction}</from-action>
<from-outcome>printAttendReportAction</from-outcome>
<to-view-id>/attend/printAttendReport.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config> // here is managed bean code
public class AttendReportBean {
// data , getters and setters
init();
//Preload in initialization block.
public void init() {
// initialize data
public String attendReport() {
// code to get attend data to go to view page(same page) it is ok
return "attendReport"; // Navigation case.
public static String getRequestParameter(String name) {
return (String) FacesContext.getCurrentInstance().getExternalContext()
.getRequestParameterMap().get(name);
public void printAttendReportListener(ActionEvent event) {
String fromYearStr = getRequestParameter("fromYearAtt");
System.out.println("fromYearStr = "+fromYearStr);
// try to get inputs through ActionListener but it gives me null
public String printAttendReportAction() {
// code to get attend data to go to print page(another page in new //window) but inputs come in default values
return "printAttendReportAction"; // Navigation case.
}attendReport.jsp
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<f:view>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
//title . styles and validations //
</head>
<body>
<h:form id="attendReportForm">/the form tag appear in running source as <form id="attendReportForm" method="post" action="/newdiwan/faces/attend/attendReport.jsp" enctype="application/x-www-form-urlencoded" >
i.e. it always submit to attendReport.jsp page
/ some inputs and outputs /
<h:commandButton onclick="return check();" id="view" action="#{attendReportBean.attendReport}" value="" styleClass="linksNumBlue" />//it works good/
// some outputs to view data /
<h:commandLink immediate="true" id="printLink" value="" action="#{attendReportBean.printAttendReportAction}" actionListener="#{attendReportBean.printAttendReportListener}" target="_blank" styleClass="linksNumBlue">
<f:attribute name="fromYearAtt" value="2009" />
<f:attribute name="fromMonth" value="01" />
<f:attribute name="toYear" value="2010" />
<f:attribute name="toMonth" value="06" />
</h:commandLink>//this has two problems 1)submit to attendReport.jsp not printAttendReport.jsp which I want to go to.
//2)does not get the inputs but return the default values only /
</h:form></body></html></f:view>I use libraries { jsf-api.jar , jsf-impl.jar , jstl-1.1.0.jar and tomahawk-1.1.6.jar } and deploy on tomcat 6.0
Im sorry for the prolongation, please help me if you can
Edited by: alynoor on Jul 8, 2010 1:51 AM
Edited by: alynoor on Jul 8, 2010 1:55 AMmy problem solved 1- i use 2 managed bean , one of request scope (used in attendReport.jsp ) and the other with session scope (used in printAttendReport.jsp)
2 - add new jsp contains the h:commandLink of the print (attendReportPrintAction.jsp)
3 - divide the view of attendReport.jsp to two subviews (each subview has its own form) one contains inputs and outputs of attend and the other contains include to (attendReportPrintAction.jsp)
<%@ include file="attendReportPrintAction.jsp" %>
4 - send and get parameters using two methods
public static Object getSessionMapValue(String key) {
return FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(key);
public static void setSessionMapValue(String key, Object value) {
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(key, value);
}faces-config.xml
<managed-bean>
<managed-bean-name>attendReportBean</managed-bean-name>
<managed-bean-class>csc.attend.bean.AttendReportBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>print_attendReportBean</managed-bean-name>
<managed-bean-class>csc.attend.bean.AttendReportBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<display-name>viewReport</display-name>
<from-view-id>/attend/attendReport.jsp</from-view-id>
<navigation-case>
<from-action>#{AttendReportBean.attendReport}</from-action>
<from-outcome>attendReport</from-outcome>
<to-view-id>/attend/attendReport.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<display-name>printReport</display-name>
<from-view-id>/attend/attendReport.jsp</from-view-id>
<navigation-case>
<from-outcome>printAttendReportAction</from-outcome>
<to-view-id>/attend/printAttendReport.jsp</to-view-id>
</navigation-case>
</navigation-rule>attendReportPrintAction.jsp
<f:subview id="printAttendReportSubView" >
<h:form id="printAttendReportForm" onsubmit="return check222();" >
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="11%">
<table width="70" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="7" height="28"><img src="../images/B-left.gif" width="7" height="28" /></td>
<td align="center" background="../images/B-bg.gif">
<!--a href="printAttendReport.jsp" class="linksNumBlue" target="_blank" >طباعة</a-->
<h:commandLink id="printLink" value="طباعة" title="طباعة" action="#{print_attendReportBean.printAttendReportAction}" target="_blank" styleClass="linksNumBlue">
</h:commandLink>
</td>
<td width="7" height="28"><img src="../images/B-right.gif" width="7" height="28" /></td>
</tr>
</table>
</td>
<td align="right"> </td>
</tr>
</table>
</h:form>
</f:subview>i hope this helps someone
Maybe you are looking for
-
Calling the system commands in Java
Hi All, How to call the system commands in java other than using exec() function.For eg, in my linux machine i have used p.exec("exit") to exit from a cshell to the prompt but it is not working.Is there any other solution for this one. Pls. do provid
-
Hi all, I am facing problem with date and time sync in Oracle VM server. Problem is that after the guest power off the guest time is getting old (16-jul-2009) . OVM server time is synced with NTP server and time is actual but guest time is not matche
-
Streaming video ad, container swf needs to be smaller
Hi everyone I've been asked to make a swf stream a FLV for an advertisement. The swf is to be hosted on the page of a local news channel, the FLV is stored elsewhere. The news channel is insisting the SWF be no bigger than 40k, the smallest i've mana
-
PROCEDURE pr_exercise ( p_userid VARCHAR2, p_filename VARCHAR2, p_logfile VARCHAR2 IS CURSOR c_exercise IS SELECT ordr.corp_name, e.exer_dt, ordr.corp_name, o.soc_sec, o.name_first, o.name_mi, o.name_last, u.ml_retail_account, e.exer_dt, e.exer_type,
-
How to take report for Employee past pay results!!!
Hi Experts, I would like to know how to generate report for employee's past pay roll, which gives information pertaining to employee's pay hike if any and other details. Please advice...subbu14blueatgmail.com Thank you in advance for your help. Regar