Hi everybody,
This is to inform that solved the problem of executing two action (of two
forms) at the same time.
YES, it does work. I had to forms one doing update in a database via a URL
that executes a servlet, and the other was doing upload of files. They both
work great, however aftter hours I noticed that I first got to do the update
in the database and then (last action) do the upload. For some reason I
don't know the other way around does not get the 2 actions done. The way the
code is now it does.
I am sending the example again and I appreciate if sombody can make
suggestions related to teh order things need to be called.
Siomara
<!-- daPubEditDocDlogContent.jsp -->
<!-- $$ BEGIN PAGE DIRECTIVE -->
<%@ page language = "java" %>
<%@ page import = "java.util.*" %>
<!-- $$ END PAGE DIRECTIVE -->
<%
String header = request.getHeader("Host");
int documentID = 0;
String documentIDStr = "";
int parentFolderID = 0;
String parentFolderIDStr = "";
String title = "";
String notes = "";
String action = "";
String pipFormRef = "";
String formTitle = "";
String user = "";
String relativePath = "";
HttpSession pipSession = request.getSession(false);
if (pipSession == null )
{
out.println("Session is NULL");
return;
}
user = (String)pipSession.getAttribute("owner");
relativePath = (String)pipSession.getAttribute("relativePath");
String appName = PIPServices.pipProperties.getProperty("appName");
documentIDStr = request.getParameter("documentID");
parentFolderIDStr = request.getParameter("parentFolderID");
if (documentIDStr != null)
{
documentID = Integer.parseInt(documentIDStr);
}
if (parentFolderIDStr != null)
{
parentFolderID = Integer.parseInt(parentFolderIDStr);
}
if (documentID == 0)
{
pipFormRef = "addADocument_PF";
action = "http://" + header + "/" + appName +
"/servlet/PIP";
formTitle = "Add a Document";
}
else
{
pipFormRef = "updateDoc_PF";
action = "http://" + header + "/" + appName +
"/servlet/PIP";
formTitle = "Edit a Document";
PIPSnapRecset myPIPSnapRecset = null;
PipServerUtil myPIPUtilObj = null;
myPIPSnapRecset=
(PIPSnapRecset)pipSession.getAttribute("myPipSnapRecset");
myPIPUtilObj =
(PipServerUtil)pipSession.getAttribute("myPIPUtilObj");
String snapURL = "http://" + header + "/" +
appName +
"/servlet/PIP?request=execSnap&snapRef=getDocInfo&documentID=" +
documentID;
String snapoutputXML = myPIPUtilObj.LoadServlet(snapURL);
Hashtable srchResults = new Hashtable();
srchResults =myPIPSnapRecset.getDataFRec(snapoutputXML, 0,
srchResults);
title = (String) srchResults.get("title");
notes = (String) srchResults.get("notes");
}
%>
<script language=javascript>
////////////////////////////////////////////////////////////////////////////
///
// submit to appropriate servlet/jsp
//
function transferData()
{
objfrm2 = document.PublishEditDocument2;
objfrm2.action = "<%=action%>";
objfrm2.method = "post";
objfrm2.submit();
objfrm1 = document.PublishEditDocument1;
objfrm1.action =
"http://localhost:8100/pip6961/servlet/UploadServlet";
objfrm1.method = "post";
objfrm1.submit();
}
</script>
<html>
<head>
<title> PIP Portal </title>
</head>
<body>
<p> <b><font color="#008080" size="4">Uci </font><font
size="4">Wizard</font></b>
<font size="4">- <b>Publish Document</b></font>
</p>
<FORM name=PublishEditDocument1 enctype="multipart/form-data">
<table border="0" width="100%" height="227">
<tr>
<td width="10%" height="25">Document:</td>
<td width="90%" height="25"><input type=file size=20
name="fname"></td>
<input type="hidden" name="user" value="<%=user%>">
<input type="hidden" name="relativePath"
value="<%=relativePath%>">
</tr>
</table>
<p>
</p>
</form>
<FORM name=PublishEditDocument2>
<table border="0" width="100%" height="227">
<tr>
<td width="10%" height="25">Title:</td>
<td width="90%" height="25"><input type="text" name="title"
size="80" value="<%=title%>"></td>
</tr>
<tr>
<td width="10%" height="109" valign="top">Notes:</td>
<td width="90%" height="109" valign="top"><textarea rows="3"
name="notes" cols="69"><%=notes%></textarea></td>
</tr>
<tr>
<input type="hidden" name="documentID"
value="<%=documentID%>">
<input type="hidden" name="parentFolderID"
value="<%=parentFolderID%>">
<input type="hidden" name="pipFormRef"
value="<%=pipFormRef%>">
<input type="hidden" name="request"
value="execPIPForm">
<td width="10%" height="21"> </td>
<td width="90%" height="21"> </td>
</tr>
<tr>
<td width="10%" height="27"> </td>
<td width="90%" height="27">
<!--
<input type="button" value="Accept" name="btnAccept"
onclick="javascript:return
transferData()">
<input type="reset" name="btnReset" value="Cancel">
-->
</td>
</tr>
</table>
<p>
</p>
</form>
</body>
</html>
-----Original Message-----
From: SriHari [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 21, 2001 6:12 AM
To: [EMAIL PROTECTED]
Subject: Re: Problems with adding files to a DB and uploading files
Hi
Patrick
The solution for this is to seperate the multipart/form-data with your other
variables
u have to either upload the file(only) first and then send the other form
variables using sessions or some other method
(or)
---
as far as my knowledge there is no other method than these
BestOfLuck :)
Sri Hari
-----Original Message-----
From: Patrick Fong [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 21, 2001 6:05 PM
To: [EMAIL PROTECTED]
Subject: Problems with adding files to a DB and uploading files
Hi
I have a JSP which has three forms in it. One form which has the normal
encoding scheme (ie application/x-www-form-urlencoded), the other which is
where the file element is at has the encoding scheme of (ie.
multipart/form-data) and the other has just one element which is the button
which calls the javascript which processes these forms.
Take the HTML code for example
<form name="f15" action="admin.jsp" method="post">
<!-- form elements to add to a DB -->
</form>
<form name="f15a" action="upLoadFile.jsp" method="post"
enctype="multipart/form-data">
<input type="file" name="filename" size="60">
</form>
<form name="f15b">
<input type="button" value="add this"
onClick="assignValues(document.f15,document.f15a)">
</form>
The Javascript simplies assigns the values of f15 to a hidden frame, which
contains the form elements to add to the DB. I have done this because I do
not think you can submit two forms on the same page. (Maybe I will try this
later, but I do not think that it will make a difference). Now my problem
isnt that the form elements are input into the DB, but that the file does
not upload.
The upload can be done on a separate page. But I need it to upload on the
same page as everything else.
The javascript submits the form at the end
upLoadForm.submit();
Any ideas?
Oh, and while on the topic, can anyone suggest a good file upload program?
I am currently using the one I found from onjava @oriellynet.com
(http://www.jaava.com/onjava/2001/04/05/example/listing1.html) It seems to
have a short filename allowance. Anyone know of a better one where I can
have longer file names, or does anyone know how to change the filename
length into something longer?
TIA
Patrick
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets