validation of document extension

R

Roy

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.
 
A

Andrew Thompson

I have been watching and learning from this newsgroup ever since I
started learning java which was four months ago,

You have been reading this group for four months but not seen
any advice against reposting a question 11 minutes after you
first post it?
 
R

Roy

Andrew Thompson said:
You have been reading this group for four months but not seen
any advice against reposting a question 11 minutes after you
first post it?

Hmmm, the first time I tried to post it the system froze up on me,
thanks for the advice.
 
A

Andrew Thompson

On 30 Nov 2004 05:43:13 -0800, Roy wrote:

(snip)
...the extenstion would
either be xls,doc,ppt, pdf, txt, or online/webform.

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

When you don't know why your code breaks, code snippets are slightly
less than useless. 'Nothing' is useless, but snippets also take up
bandwidth.
....
String[] rType = {".xls", ".doc", ".txt", ".pdf", ".ppt"};

Why is rType only mentioned once? You declare it and initialise it,
but it do not reference it again in the snippets you supply..
...
If anyone can help me please offer your input, some of the code has
been omitted for security purpose.

Rewrite it to remove the secure code and post a self-contained
example[1] that fails. ..It *does* fail, right[2]?

[1] <http://www.physci.org/codes/sscce.jsp>

[2] Your post does not actually mention..
a) The result of the code you have (including exact error messages).
<http://www.physci.org/codes/javafaq.jsp#exact>
b) The behaviour you expected, and how the observed bahaviour
differs from that.
c) A question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top