Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Ajax passing file parameter through ajax
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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



Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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
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
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
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 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
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
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
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..."; String qry3="select age from table13"; string q=Insert into emp values(?,?,?); int update=prep.executeUpdate(q); prep.setString(1,qry1); prep.setString
JSP:Passing query as parameter - Java Beginners
JSP:Passing query as parameter  Hi Friends, I have a real tough..."; String qry3="select age from table13"; string q=Insert into emp values(?,?,?); int update=prep.executeUpdate(q); prep.setString(1,qry1); prep.setString
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
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
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
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
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
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
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
run a batch file through javascript
run a batch file through javascript   How to run a batch file through javascript without prompting
How to pass parameter through drop down list using session management in jsp??
How to pass parameter through drop down list using session management in jsp??  How to pass parameter through drop down list in the URL and access it on same jsp page using session management
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 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
AJAX file upload
AJAX file upload If you want to upload file asynchronously means without... files. URL for Code http://www.webtoolkit.info/ajax-file-upload.html Demo URL http://www.webtoolkit.info/demo/ajax-file-upload Description
File uploading - Ajax
File uploading  hi friends, how to uploading the file by using "AJAX".Please send the complete source code for this application   where u want to store the file Can u specify
 

 

 

DMCA.com