Validation of string extension and editing documents

From: Roy (rbynum_at_kansascommerce.com)
Date: 11/30/04


Date: 30 Nov 2004 05:32:50 -0800

Hello

I have look at this site for some time now getting tidbits of
information and knowledge from the people here, I am new to
programming literally, my background is business but I have been
thrust into java since July.

It has been a very unique experience with only two weeks of training
*S* I have a task where I am trying to validate a file extension to
make sure it is valid.The extension would either be xls, doc, text,
ppt, online/webform and pdf.

Here is the code I have been working with if anyone has any ideas
please help me.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="db" scope="request"
class="com.kdoc.beans.DBConnectionInfo"/>
<%@ taglib uri= "../WEB-INF/c.tld" prefix="c"%>
<%@ taglib uri= "../WEB-INF/taglib48.tld" prefix="dbt" %>
<%//<c:set var="Doc" value="${param.Doc}" />
//<c:if test="${!empty Doc}"><c:redirect url="${Doc}"/></c:if> %>
<% String DocName="";
if(request.getParameter("DocName")!=null) {
 DocName = (String)request.getParameter("DocName"); }
 String TITLE="";
if(request.getParameter("DOC_TITLE")!=null) {
 TITLE = (String)request.getParameter("DOC_TITLE"); }
 String[] rType = {".xls", ".doc", ".txt", ".pdf", ".ppt"};
%>
<dbt:openConnection driver="<%= db.getDbDriverName() %>" url="<%=
db.getDbUrl() %>" user="<%= db.getDbUser() %>" password="<%=
db.getDbPassword() %>" id="A"/>
<dbt:setQuery id="A" res="rsCatDOC">
<dbt:setSQL>SELECT (CCAT_ID), rtrim(CCAT_TITLE), CCAT_RANK from
OLAPPS.WIA_CCAT</dbt:setSQL>
</dbt:setQuery >
<dbt:openConnection driver="<%= db.getDbDriverName() %>" url="<%=
db.getDbUrl() %>" user="<%= db.getDbUser() %>" password="<%=
db.getDbPassword() %>" id="B"/>
<dbt:setQuery id="B" res="rsDOC">
<dbt:setSQL>SELECT (DOC_ID), rtrim(DOC_TITLE), DOC_RANK from
COREWEB.CORE_DOCS</dbt:setSQL>
</dbt:setQuery >

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>WIADOCS</title>
</head>

<body>

 
 <form action="<%= request.getRequestURI() %>" method="get"
enctype="multipart/form-data" class="formstyle" >
 
<select name="CatDoc" class="formselectbox" size="1" id="CatDoc" >
<dbt:forEachRow res="rsCatDOC">
<dbt:getColumn res="rsCatDOC" position="1" id="CCAT_ID" />
<dbt:getColumn res="rsCatDOC" position="2" id="CCAT_TITLE" />
<option value="<%=CCAT_ID %>"><%=CCAT_TITLE %></option>
</dbt:forEachRow></select>
<select name="Doc" class="formselectbox" size="1" id="Doc">
<dbt:forEachRow res="rsDOC">
<dbt:getColumn res="rsDOC" position="1" id="DOC_ID" />
<dbt:getColumn res="rsDOC" position="2" id="DOC_TITLE" />
<option value="<%=DOC_ID %>"><%=DOC_TITLE %></option>
</dbt:forEachRow>
</select>
<input name="Submit" type="submit" id="submit" value="Submit" />

<label>Document input field:</label><br>
  <input type="text" name="DocName">
  
 </form>
<%=DocName %><%=TITLE %>
</body>
</html>
<dbt:closeConnection id="A"/>
<dbt:closeConnection id="B"/>



Relevant Pages

  • Re: ExtractFileExt() or OpenDialog1.FileName Issue
    ... I am analysisng the file extension so that if it is .mp3 it will play ... Now the problem with this is it demands a PAnsiChar to work, ... this to a string, and then putting the string in the the function. ... Function is given by the OpenDialog Filename property: ...
    (comp.lang.pascal.delphi.misc)
  • Re: Can this be written better?
    ... VB has various functions which will search for a substring inside a string and return its position for you. ... There are also functions that will return a specified number of characters of a string for you, from either the left side, right side or somewhere in the middle. ... if you want to remove the file extension no matter what it is then you need to do it differently and you also need to take into account that on modern versions of Windows a file extension can have more than three characters. ...
    (microsoft.public.vb.general.discussion)
  • RE: Change File Extension before importing
    ... Dim strOldName as String ... Dave Hargis, Microsoft Access MVP ... wondering if there's some code that would change the file extension before ...
    (microsoft.public.access.externaldata)
  • Re: Can this be written better?
    ... character is the only ... my previously posted code to strip ... off a file extension is fine as it stands. ... Private Function stripExtension(s1 As String) As String ...
    (microsoft.public.vb.general.discussion)