Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 2nd, 2005, 12:16 AM
Registered User
Join Date: Apr 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ruchilalla
Default To mrjmukesh thanx its wkin 4me need more help

the code is wking fine actually my application :Uploads the file and stores it on d:\ using MultiRequest class .so now any type of file is getting stored .Although i am getting an alert but the file still gets stored :
Do go thru the code thanku 4 all th help

<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
<%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
<%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%>
            Web Application Page
<script language="JavaScript">
function checkFileExtension(parafilevalue)
    var file=parafilevalue.split('.');

        return false;
    var fileext=file[1].toLowerCase();
    return validType

function validateForm()
    if(!checkFileExtension(document.myForm.myFile1.val ue))
        alert('Upload a file with extension xml');
        return false;
    return document.myForm.Submit();


       <FORM NAME="myForm"
   <INPUT type="file" name="myFile1" accept="text/xml" >

   <INPUT TYPE="submit" VALUE="Upload File" onclick="validateForm()">

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.ServletException;
import com.oreilly.servlet.MultipartRequest;

public class fwdservlet extends HttpServlet
public void init(ServletConfig config)throws ServletException
public void doPost(HttpServletRequest request,HttpServletResponse response)throws
    PrintWriter out=response.getWriter();
   out.println("<html><head><title>File Stored!</title></head>");
   out.println("<body><h1>File Stored!</h1></body></html>");

MultipartRequest multi = new MultipartRequest(request,"d:\\");


Old May 2nd, 2005, 12:59 AM
Authorized User
Join Date: Apr 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jmukesh Send a message via Yahoo to jmukesh

Just Replace this line

 <INPUT TYPE="submit" VALUE="Upload File" onclick="validateForm()">

with :

 <INPUT TYPE="button" VALUE="Upload File" onclick="validateForm()">


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.