Home Answers Viewqa Ajax passing file parameter through ajax

 
 


harita
passing file parameter through ajax
3 Answer(s)      4 years and 10 months ago
Posted in : Ajax

View Answers

August 7, 2008 at 5:19 PM


Hi friend,

file1.jsp



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

<HTML>

<HEAD>

<TITLE> passing file using jsp and ajax </TITLE>

<script>


function fileParam(){



xmlHttp=GetXmlHttpObject()

if (xmlHttp==null) {

alert ("Browser does not support HTTP Request")

return

}



var filename= document.form.filename.value;



var url="http://localhost:8080/file2.jsp";;

url=url+"?filename="+filename;

xmlHttp.onreadystatechange=stateChanged

xmlHttp.open("GET",url,true)

xmlHttp.send(null)



}

function stateChanged() {



if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {



var showdata = xmlHttp.responseText;

alert(showdata);

}

}



function GetXmlHttpObject()

{

var xmlHttp=null;

try

{

// Firefox, Opera 8.0+, Safari

xmlHttp=new XMLHttpRequest();

}

catch (e)

{

//Internet Explorer

try

{

xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

}

catch (e)

{

xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

}

}

return xmlHttp;

}


</script>

</HEAD>


<BODY>

<br><br>

<center>

<table bgcolor="#efefef">

<tr><td colspan=3 align="center"><b></b></td></tr>

<tr><td colspan=3 align="center"><b>&nbsp;</b></td></tr>

<tr>

<td>


<form name="form">

<fieldset style="width:250px;">


<legend><b>#Form</b></legend>

<table width="250px" border=0 align="center">



<tr><td>File</td><td><input type="file" name="filename"></td></tr>



<tr>

<td colspan=2 align="center">

<input type="button" name="button" value="Button" onclick="fileParam();">

</td>

</tr>


</table>

</fieldset>

</form>


</td>


</tr>

</table>

</center>

</BODY>

</HTML>

August 7, 2008 at 5:21 PM


file2.jsp


<%

String filename = request.getParameter("filename");

out.println(filename);

System.out.println("filename" + filename);

%>

-------------------------------------------------------------------

Read for more information.


http;//www.roseindia.net/jsp/


Thanks.

August 7, 2008 at 6:41 PM


Hi, thanks for sending solution for this.

U have send the code for the server side, in which only file name we are getting.
but how can i download the file by using struts.upload.FormFile.









Related Pages:
passing file parameter through ajax - Ajax
passing file parameter through ajax  I have file parameter in jsp file, i need to pass it to server side through ajax. how i can i do that.   Hi friend, file1.jsp passing file using jsp
passing .properties file as a parameter to another function
passing .properties file as a parameter to another function  passing .properties file as a parameter to another function in an jsp file
passing .properties file as a parameter to another function
passing .properties file as a parameter to another function  passing .properties file as a parameter to another function in an jsp file
passing .properties file as a parameter to another function
passing .properties file as a parameter to another function  passing .properties file as a parameter to another function in an jsp file
passing .properties file as a parameter to another function
passing .properties file as a parameter to another function  passing .properties file as a parameter to another function in an jsp file
Applet - Passing Parameter in Java Applet
Applet - Passing Parameter in Java Applet   ... and passing parameter in applet, a example is given below. In this example, we... case applet should display "Welcome in Passing parameter in java applet
Java parameter passing
Java parameter passing  What type of parameter passing does Java support
Passing Parameter - JSP-Servlet
Passing Parameter  I would like to ask how to pass a parameter from javascript section into the jsp section.It will be something like...; answer<%; <---I'm stuck here passing the var
Parameter passing from jsp page to jsp page - JSP-Servlet
Parameter passing from jsp page to jsp page  Hi I intends to pass the parameters that I received from previous page through query String. I get all parameter in respective string variables. I have to passed the parameters
Passing Parameter - JSP-Servlet
Passing Parameter  Hi, it'me again. Below is the set of code that I get from your solution entitled droplist that read from database. It do read from..., there's var answer. I need to pass this parameter back into the jsp part, how should i do
Passing a parameter using URL string
Passing a parameter using URL string  How to pass a parameter using the URL string in a JSF application
passing parameter from Java code to CSS file - Design concepts & design patterns
passing parameter from Java code to CSS file  hi, i have to pass a string variable from by java code to a CSS file so that i can use that variable in my CSS file. Plz help me as soon as possible
java file with many methods - Ajax
java file with many methods  I have to send response to a java file where there are many methods and I have to call one of them by passing parameter .How can I do
passing values between jsp file through hyperlink in div tag
passing values between jsp file through hyperlink in div tag  <p>hi please help me to solve this. i have searchproj.jsp and updateproj.jsp. In searchproj.jsp values r retrieved from db as follows </p> <pre class
passing parameter from html to applet
passing parameter from html to applet  how to pass the following from HTML to applet in Java code - font size,font style,font size?give me suitable code
Passing Parameter with <jsp: include>
Passing Parameter with <jsp: include>     ... a file in a jsp page. While using <jsp:param> we are adding the file at run time. The code of the program is given below
Main function parameter in C language - Ajax
Main function parameter in C language  Please let me know how... line arguement.Also how is fgetpos() and fsetpos() used in file operation .... The fgetpos function gets the current value of the stream argument?s file
Passing Parameters - JSP-Servlet
Passing Parameters  Hi I have to pass parameter like... First Name /**SECOND PAGER upto this page I passed the parameter through query string **/ Name /** I have to redirect all received params through
JSP parameter passing throught out web app
JSP parameter passing throught out web app  i want to pass one param from page1.jsp page to page4.jsp page but in between this i need to navigate page3.jsp and page2.jsp.Please help me to understand how could i transfer param
Ajax form element - Ajax
Ajax form element  I have problem in passing a value into form feild using ajax. I want to get the value is as a parameter. Can some one help me plz
Passing Parameter Values to another jsp in Query Strings
Passing Parameter Values to another jsp in Query Strings  HI ALL, I m trying to pass a variable value to another JSP using query string... response.sendRedirect("http://localhost:8080/SWIFT/index.jsp?loginid='"+loginid
JSP:Passing query as parameter - Java Beginners
JSP:Passing query as parameter  Hi Friends, I have a real tough time in finding the solution of a problem. I am here to find a real solution of my problem. Please help me solve this problem. My Problem is: I have 3 query
JSP:Passing query as parameter - Java Beginners
JSP:Passing query as parameter  Hi Friends, I have a real tough time in finding the solution of a problem. I am here to find a real solution of my problem. Please help me solve this problem. My Problem is: I have 3 query
Locale Specific Date validations through JavaScript/Ajax...
Locale Specific Date validations through JavaScript/Ajax...  Hi, I....), how to manipulate date validations through JavaScript or Ajax? Thanks... in JSP file. For example You if your validation function is like
Passing parameter over Form to BackingBean - Java Server Faces Questions
Passing parameter over Form to BackingBean  Dear User, i have problems concerning passing parametes from form to my backing bean. I have... here, my Bean Code. This is the form
Ajax File Upload Example
Ajax File Upload Example       This application illustrates how to upload a file using servlet through the Ajax technology. In this example you simply create a file
Passing Multi select list box values using ajax to get values to dependent list box
Passing Multi select list box values using ajax to get values to dependent list box  Hi, I have a jsp page which has 3 dependent list boxes with multiple selection. How can i pass multiple selected values through ajax to retrieve
Passing parameters to XSLT style sheets
Passing parameters to XSLT style sheets       Passing parameters to XSLT style sheets We can pass parameter for transformation using jQuery as :  <
Passing Parameter Using Html Form
Passing Parameter Using Html Form       This is a very simple example in which we are going...;} }  web.xml file for this program
Ajax Chat
Chat This tutorial will walk you through the step in order to create an AJAX... manner. JSON AJAX Web Chat This tutorial will walk you through the steps to create... Ajax Chat       
Passing classid or name in request using Jquery
with parameter so that I save my file with that name. Can some body help me as I am...Passing classid or name in request using Jquery  Hi, I am new... filename,userid that I am passing to the servlet to upload a file.I have created
any alternaive for AJAX - Ajax
confused and find it difficult to get good Ajax document just go through the given link... developing a web application for my final year project. very one knows AJAX which... any... given below to create application in ajax
Argument Passing
Passing Argument in Java  hi this is my code class Test { void meth(int i, int j) { i *= 2; j /= 2... to the parameter of the subroutine have no effect on the argument plz clear my
Argument Passing
); print a=30 & b=10 As changes made to the parameter of the subroutine have
Argument Passing
); print a=30 & b=10 As changes made to the parameter of the subroutine have
Argument Passing
); print a=30 & b=10 As changes made to the parameter of the subroutine have
Argument Passing
); print a=30 & b=10 As changes made to the parameter of the subroutine have
Argument Passing
); print a=30 & b=10 As changes made to the parameter of the subroutine have
Argument Passing
); print a=30 & b=10 As changes made to the parameter of the subroutine have
pass parameter - file - Java Beginners
pass parameter - file  Hi, I want to pass paramter file to method... immediately. file.jsp ========== File Parameter Use Please Select the file 2. Display.java
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
Ajax
Ajax  I want message print on jsp page that come from servlet through ajax.please help me out
Ajax
Ajax  I want message print on jsp page that come from servlet through ajax.please help me out
How can I paginate a table which has shown in a div through Ajax in client side without using database
How can I paginate a table which has shown in a div through Ajax in client side without using database   The table is shown by calculation in a PHP script file so The data not store any where so please give me the way to paginate
Ajax Tutorial
Ajax Tutorial In this section we will read about the Ajax. This section will describe you about the Ajax. After reading this section you will be better understand What is Ajax, Advantages of Ajax, Ajax XMLHttpRequest, How Ajax works
How to access session values through Ajax?
How to access session values through Ajax?  Suppose in a servlet a variable userName is kept in session. How can I access this variable from JSP through AJAX? Is it possible
passing value of radio button
passing value of radio button  hi,i have 3 jframe built using the GUi editor in net beans 6.9. i have two radio button in the first jframe.i have to get the selected item appear on the 3rd frame after passing through the second

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.