validation of document extension

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


Date: 30 Nov 2004 05:43:13 -0800

Hello
I have been watching and learning from this newsgroup ever since I
started learning java which was four months ago, I don't have a
programmers background and this is really new and exciting to me. I am
trying to write a jsp page that when a user wants to put a document,
file in the database the page will verify that the extension on the
file is correct, believe me some people don't really know how to
upload files correctly *S*, I am stuck at the point of trying to get
the page to recognize the document, for instance the extenstion would
either be xls,doc,ppt, pdf, txt, or online/webform.

Here is part of the code I have been working with.

<% 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"};
%>

<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"/>

If anyone can help me please offer your input, some of the code has
been omitted for security purpose.
Thanks.



Relevant Pages

  • Re: [OT] [Provocation] are Java programmers unfriendly and harsh people?
    ... Since I'm learning java, I thought java.help would be a good place to learn something, in addition to having fun reading messages. ... I must say that I'm getting tired of this newsgroup: there's rarely a day where there is not at leas one ... probably deserve it, but there are more posts complaining about lack of question marks than there are worthwhile contributions. ... going to get a grammar lesson if they post here? ...
    (comp.lang.java.help)
  • Re: wading back to Java
    ... Sun's tutorials. ... Books. ... you could use google groups to search this newsgroup for book recommendations? ... I found O'Reilly's "Learning Java" to be useful. ...
    (comp.lang.java.programmer)
  • Re: validation of document extension
    ... >> I have been watching and learning from this newsgroup ever since I ... >> started learning java which was four months ago, ... > first post it? ...
    (comp.lang.java.programmer)