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



Home Answers Viewqa Java-Beginners pass parameter - file
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


babu
pass parameter - file
1 Answer(s)      5 years and 6 months ago
Posted in : Java Beginners



Advertisement
View Answers

May 5, 2009 at 3:04 PM


Hi Friend,

If you are working with the JSP and Servlet then this code can be understood immediately.

file.jsp
==========
<%@ page language="java" %>

<html>
<head>
<title>
File Parameter Use
</title>
</head>
<body>
<form name="frm" action="fileServlet" method="POST">
Please Select the file <input type="file" name="filename" />
<br><input type="submit" value="Show File Name" />
</form>
</body>
</html>

2. Display.java
================

package roseindia;
public class Display{
public Display(){}

public void showFile(String filename){
System.out.println("The file browsed is = "+filename);
}
}


3. File Servlet
================
package roseindia;

import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class fileServlet extends HttpServlet{
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
ServletOutputStream out = response.getOutputStream();
String filename= request.getParameter("filename");
// Created an instance of Display class
Display ds = new Display();
// Invoking showFile() method
System.out.println(" Invoking method showFile ->");
ds.showFile(filename);
}
}

We hope that this will be helpful to you.

Thanks
RoseIndia Team



Related Tutorials/Questions & Answers:
pass parameter names and values
pass parameter names and values  What is the <jsp:param> standard action?   The <jsp:param> standard action is used with <jsp:include> or <jsp:forward> to pass parameter names and values
how to pass the parameter in callable statement
how to pass the parameter in callable statement  calstat=conn.prepareCall("{call studentrc(?,?,?,?,?)}"); // it show error parameter value is null...=smark1,mark2=smark2,total=stotal where Regno=Regno; end;// how can i pass the parameter
Advertisements
How to pass query as parameter? - JSP-Servlet
How to pass 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
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
SQL Out Parameter
SQL Out Parameter       SQL Out Parameter allows the stored procedure to the pass data... an example from SQL Out Parameter .In this Example we create a procedure 'abc
Init Parameter
Init Parameter  How set Init Parameter in servlet
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
SQL Out Parameter
SQL Out Parameter       SQL Out Parameter allows the stored procedure to the pass data value ... from SQL Out Parameter .In this Example we create a procedure 'abc
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 - 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 this: function change() { var answer = document.getElementById('selc').value
validate parameter before using it
validate parameter before using it   How to validate the parameter before using it in JSP
Java parameter passing
Java parameter passing  What type of parameter passing does Java support
pass method reference in java
pass method reference in java  How to pass method reference in Java
Is Java pass-by-reference?
Is Java pass-by-reference?  Is Java pass-by-reference
Passing Parameter - JSP-Servlet
, there's var answer. I need to pass this parameter back into the jsp part, how should i do
JavaScript pass arguments
JavaScript pass arguments   How to pass dynamic arguments to the functions in JavaScript
PHP Pass Post Data
PHP Pass Post Data  How to pass POST data to the PHP-CGI
you pass a variable by value.
you pass a variable by value.  How do you pass a variable by value... $a = &$b /*--------------Pass By value----------------*/ function add($a) { return ++$a; } add($a); /*---------------Pass by reference
optional parameter of Test annotattion
optional parameter of Test annotattion   What are two optional parameters of @Test annotation ?   The Test annotation supports two optional... parameter, timeout, causes a test to fail if it takes longer than a specified amount
Pass by Reference - Java Beginners
Pass by Reference  Hi Friends, What is Pass by value and Pass by Reference?can u please explain with examples.is java supports Pass by reference?  Hi Friend, Pass By Value: It refers to pass the variables
optional parameter of Test annotattion
optional parameter of Test annotattion   The Test annotation supports two optional parameters. The first, expected, declares that a test method should throw an exception. If it doesn't throw an exception or if it throws
parameter meta data - JDBC
parameter meta data   i wnts to know about the finition of parameter in jdbc as well as the diffrent methods used in parameter meta data  Hi friend, public interface ResultSetMetaData An object that can be used
Parameter Tag:
Parameter Tag:       bean:parameter...) of the specified request parameter. This tag retrieve the value of the specified request parameter and define the attribute of  type String or String[] in page scope
Can I pass a
Can I pass a   Suppose I have servlet named Name.java and there is a variable String name holding a value "Roseindia". I have collected the value to Getname.jsp via ajax. Now how can I pass this value to scriplet without page
java pass by reference
java pass by reference  i understood java always pass arguments by pass by value so that the original value does not change...... but i want to know how we change the value and make it effect the original value by passing
objective c pass by value
objective c pass by value   How to pass value by reference in objective c?   - (void)parentFunction { int i = 0; [self... to be able to modify i, you would have to pass the value of the reference by doing
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
pass to next page
pass to next page  I am working on a school project no server client side only. 1st page you enter data such as name, address, DoB etc.(textboxes & dropdowns) after clicking submit the data needs to be displayed in a frame
PHP add parameter to url - PHP
PHP add parameter to url  need an example of parse_url in PHP. Thanks in advance
Static Parameter
Static Parameter       In this section, we will develop a simple application to access the static parameters. We will use a JavaBean to set and get the static parameters. Each static parameter has a value
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
 

 

 

DMCA.com