upload and download

I am creating a simple web application which consist file upload, download and viewing the file. When the users view the file, the users should not make the local copy of that file.Please let me know.Thanks,nanda
[240 byte] By [nansun] at [2007-11-26 7:15:29]
# 1

<script type="text/javascript">

function updateTheForm ()

{

alert("About to submit form");

document.form[0].pdtlaction="update"

document.forms['addUserForm'].submit();

}

</script>

<html:form action="AddUser.do?do=addUser" enctype="multipart/form-data">

<html:button property="update" onclick="javascript:updateTheForm();">Submit</html:button>

</html:form>

ssram_cbe at 2007-7-6 18:50:40 > top of Java-index,Web & Directory Servers,Portal Servers...
# 2

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<link type="text/css" href="stylesheets/master.css" rel="stylesheet">

<script language="JavaScript" src="javascripts/master.js"

type="text/javascript"></script>

<title>LTC SEP - Provider Facility Document Template Library - Maintain

Folder</title>

</head>

<body>

<SCRIPT>

var folderName='Staff';

var folderDescShort='Folder to group staff documents';

var folderDescLong='Folder containing Templates for Documents Maintained for Staff';

var modifyFolderSettings='';

var deleteFolder='';

var addNewSections='';

function validateForDirty(link)

{

var folderName1=document.maintainfolder.foldername;

var folderDescShort1=document.maintainfolder.folderDescShort;

var folderDescLong1=document.maintainfolder.folderDescLong;

var modifyFolderSettings1=document.maintainfolder.modifyFolderSettings;

var deleteFolder1=document.maintainfolder.deleteFolder;

var addNewSections1=document.maintainfolder.addNewSections;

if(document.maintainfolder.dirty.value=='true' &&

(

folderDescShort1.text!=folderDescShort ||

folderName1.text!=folderName ||

folderDescLong1.text!=folderDescLong ||

modifyFolderSettings1.options[modifyFolderSettings1.options.selectedIndex].text !=modifyFolderSettings ||

deleteFolder1.options[deleteFolder1.options.selectedIndex].text!=deleteFolder ||

addNewSections1.options[addNewSections1.options.selectedIndex]!=addNewSections) )

{

if(!confirm('Do you want to discard the changes?'))

return false;

}

return redirect(link);

}

function makeDirty()

{

document.maintainfolder.dirty.value='true';

}

</SCRIPT>

<TABLE class="tableBorder" CELLPADDING="0" CELLSPACING="0" WIDTH="100%"

HEIGHT="100%">

<TR>

<TD WIDTH="100%" HEIGHT="15%">

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">

<TR>

<TD WIDTH="50%"><IMG SRC="images/Care_411_281.gif" alt="Care 411"></TD>

<TD WIDTH="50%" ALIGN="RIGHT" class="titleFontColor">LTC SEP Long-Term Care Single Entry Point System </TD>

</TR>

</TABLE>

</TD>

</TR>

<TR>

<TD WIDTH="100%" HEIGHT="80%">

<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" HEIGHT="100%"

class="topBorder">

<TR>

<TD WIDTH="18%">

<TABLE CELLPADDING="0" CELLSPACING="0" WIDTH="100%" HEIGHT="100%"

class="leftMenuBorder">

<TR>

<TD height="50" class="welcomeUser"><SCRIPT type="text/javascript">getLocalTime();</SCRIPT>

Welcome <b>Mr. John Doe</b></TD>

</TR>

<TR valign="top">

<TD class="formLabel">

<b>What would you like to do?</b>

<a href="pdsk-provider_profile.html">Manage Provider Facility

Profile</a>

<a href="cddl-search.html">Manage Client Profile</a>

<a href="cddl-search.html">Search

Client</a>

<a

href="cddl-application_for_service.html">Add New Client</a>

<a href="pdsk-provider_account_preferences.html">Manage Your

Account Preferences</a></TD>

</TR>

<TR valign="bottom">

<TD class="formLabel"><SCRIPT>getRequiredFieldText()</SCRIPT>
< ;SCRIPT>getCancelText()</SCRIPT>

</TD>

</TR>

</TABLE>

</TD>

<TD WIDTH="82%" ALIGN="CENTER" VALIGN="TOP">

<table border="0" cellpadding="0" cellspacing="0" width="100%"

height="100%" class="bottomBorder">

<tr>

<td class="applicationTitleBkg">

<table border="0" cellpadding="0" cellspacing="0" width="100%">

<tr>

<td height="50" align="left" class="appTitleFontColor"> Provider

Facility Document Template Library - Maintain Folder</td>

<td height="50" align="right"><input type="submit"

class="regularbtn" name="logout" value="Logout"

onclick="confirmAndRedirect('genl-login.html',LOGOUT);"></td>

</tr>

</table>

</td>

</tr>

<tr>

<td class="toolbarBkg">

<table border="0" cellpadding="0" cellspacing="0" width="100%">

<tr>

<td height="50" align="left"><INPUT TYPE="BUTTON"

VALUE="Return to Template Library" class="regularbtn"

onclick="return validateForDirty('pdtl-document_template_library.html/default.htm');" />

<INPUT TYPE="BUTTON" VALUE="Add New Folder" class="regularbtn"

onclick="return validateForDirty('pdtl-maintain_folder.html');" />

<INPUT TYPE="BUTTON" VALUE="Add New Section" class="regularbtn"

onclick="return validateForDirty('pdtl-maintain_section.html');" /></td>

</tr>

</table>

</td>

</tr>

<tr>

<td ALIGN="center" width="100%" class="contentBkgColor">

<form method="post" name="maintainfolder">

<Input Name="dirty" type="Hidden" value="false">

<table ALIGN="CENTER" cellpadding="0" cellspacing="0" border="0">

<tr>

<td align="left" class="cellBorder"><span class="formLabel">Folder

ID </span></td>

<td Input name="folderId" type="Hidden" value="folderId" align="left" class="trbBorder"><span class="formLabel">FLD0099999</span></td>

</tr>

<tr>

<td align="left" class="lbrBorder"><span class="formLabel">Folder

Name <span class="reqformLabel">*</span></span></td>

<td class="rbBorder"><input name="folderName" type="text" width="25" size="30"

height="50" value="Staff" onchange="makeDirty()" class="txtMedium" /></td>

</tr>

<tr>

<td align="left" class="lbrBorder"><span class="formLabel">Folder

Description - Short</span></td>

<td class="rbBorder"><input name="folderDescShort" type="text" size="45"

value="Folder to group staff documents" onchange="makeDirty()" class="txtMedium" /></td>

</tr>

<tr>

<td align="left" class="lbrBorder"><span class="formLabel">Folder

Description - Long</span></td>

<td class="rbBorder"><textarea name="folderDescLong" cols="100" rows="2"

onchange="makeDirty()" class="txtAreaMedium">Folder containing Templates for Documents Maintained for Staff</textarea></td>

</tr>

</table>

</form>

</td>

</tr>

<tr>

<td VALIGN="Center" HEIGHT="100%" class="contentBkgColor">

<table ALIGN="CENTER" cellpadding="0" cellspacing="0" border="0"

class="tableBorder">

<thead class="tableHeader">

<tr>

<td class="cellBorder"><span class="formLabel">Security

Attribute</span></td>

<td class="trbBorder"><span class="formLabel">Granted To</span></td>

</tr>

</thead>

<tbody>

<tr>

<td align="left" class="lbrBorder"><span class="formLabel">Modify

Folder Settings</span></td>

<td align="left" class="rbBorder"><SELECT id="modifySettings" onchange="makeDirty();" MULTIPLE

Class="txtMedium" size=3>

<OPTION VALUE="a1">Managers</options>

<OPTION VALUE="a2">supervisors</options>

<OPTION VALUE="a3">staff</options>

</SELECT></td>

</tr>

<tr>

<td align="left" class="lbrBorder"><span class="formLabel">Delete

Folder</span></td>

<td align="left" class="rbBorder"><SELECT id="deleteFolder" onchange="makeDirty();" MULTIPLE

Class="txtMedium" size=3>

<OPTION VALUE="a1">Managers</options>

<OPTION VALUE="a2">supervisors</options>

<OPTION VALUE="a3">staff</options>

</SELECT></td>

</tr>

<tr>

<td align="left" class="lbrBorder"><span class="formLabel">Add

New Sections</span></td>

<td align="left" class="rbBorder"><SELECT id="addNewSections" onchange="makeDirty();" MULTIPLE

Class="txtMedium" size=3>

<OPTION VALUE="a1">Managers</options>

<OPTION VALUE="a2">supervisors</options>

<OPTION VALUE="a3">staff</options>

</SELECT></td>

</tr>

</tbody>

</table>

</td>

</tr>

<tr>

<td VALIGN="left" HEIGHT="100%" class="contentBkgColor">

<table ALIGN="CENTER" cellpadding="0" cellspacing="0" border="0">

<tr>

<td colspan="2" ALIGN="left" VALIGN="CENTER" width="100%"

HEIGHT="100%">

<INPUT type="button" value="Cancel" class="regularbtn"

onclick="return validateForDirty('pdtl-maintain_folder.html');">

<INPUT type="button" value="Update" class="regularbtn"

onclick="confirmAndRedirect('pdtl-maintain_folder.html',UPDATE);">

<INPUT type="button" value="Delete" class="regularbtn"

onclick="confirmAndRedirect('pdtl-document_template_library.html',DELFOLDER);"& gt;

</td>

</tr>

</table>

</tr>

</table>

</TD>

</TR>

</TABLE>

</TD>

</TR>

<TR>

<TD WIDTH="100%" HEIGHT="5%">

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">

<TR>

<TD class="formLabel"><SCRIPT>bottomLink();</SCRIPT></TD>

</TR>

</TABLE>

</TD>

</TR>

</TABLE>

</body>

</html>

nansun at 2007-7-6 18:50:40 > top of Java-index,Web & Directory Servers,Portal Servers...
# 3

link to action class

<html:link page="/createFolder.do?entry=first">Add New</html:link>

map like this in action mapping

<global-forwards>

<forward name="sucess" path="/jsp/sucess.jsp"/>

</global-forwards>

<action attribute="attribute" input="/jsp/profile/CardProfileView.jsp" name="cardprofile" path="/createCardProfile" scope="request"

attribute="attribute"

type="com.fss.scms.action.profile.CreateCardProfile">

<forward name="get" path="/jsp/profile/CardProfileView.jsp"/>

</action>

In action class check if the request comes for the first time get the id and fwd to th einput jsp.

Strin folderId="";

Strin url="";

//ProductPortfolio portfolioBean = getBean(formbean);

String entry = formbean.getEntry();

if (entry.equals("first")) {

log.writeLog("to get the datas");

folderId= portfoliodao.FolderID();

url = "get";

} else {

portfoliodao.createPortfolio(portfolioBean);

url = "sucess";

}

} catch (BeansException e) {

e.printStackTrace();

}

formbean.setFolderId(folderId);

request.setAttribute("attribute", formbean);

forward = mapping.findForward(url);

return (forward);

//this function is to get the next folderid

public String getFolderd() throws HibernateException {

ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(

new String[] { "ProfileConfiguration.xml" });

ProfileIdGenerator dao = (ProfileIdGenerator) appContext

.getBean("idGenerator");

String profileId = dao.getMaxId();

if (profileId != null) {

String sval = "";

String a = profileId.substring(3, 10);

int inta = Integer.parseInt(a);

int intb = inta + 1;

String strc = String.valueOf(intb);

for (int i = 1; i <= 6 - (strc.length()); i++) {

sval = sval.concat("0");

}

sval = sval.concat(strc);

String Yval = profileId.substring(0, 4);

profileId = Yval.concat(sval);

}else

profileId = "key000001";

return profileId;

}

public String getMaxId() throws HibernateException {

log.writeLog("generating Id");

String id = null;

Session session = getSession();

id = (String) session.createQuery(

"SELECT max(cp.cp_uniqeId) FROM CardProfile cp")

.uniqueResult();

session.close();

return (id);

}

ssram_cbe at 2007-7-6 18:50:40 > top of Java-index,Web & Directory Servers,Portal Servers...
# 4
no replyMessage was edited by: nansun
nansun at 2007-7-6 18:50:40 > top of Java-index,Web & Directory Servers,Portal Servers...