pass parameter - file

pass parameter - file

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... The Tutorial illustrate an example from SQL Out Parameter .In this Example we create
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
Init Parameter
Init Parameter  How set Init Parameter in servlet
SQL Out Parameter
SQL Out Parameter       SQL Out Parameter allows the stored procedure to the pass data value ... illustrate an example from SQL Out Parameter .In this Example we create a procedure
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
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
Java parameter passing
Java parameter passing  What type of parameter passing does Java support
validate parameter before using it
validate parameter before using it   How to validate the parameter before using it in JSP
ModuleNotFoundError: No module named 'parameter'
ModuleNotFoundError: No module named 'parameter'  Hi, My Python... 'parameter' How to remove the ModuleNotFoundError: No module named 'parameter' error? Thanks   Hi, In your python environment you
PHP Pass Post Data
PHP Pass Post Data  How to pass POST data to the PHP-CGI
JavaScript pass arguments
JavaScript pass arguments   How to pass dynamic arguments to the functions in JavaScript
ModuleNotFoundError: No module named 'Pass'
ModuleNotFoundError: No module named 'Pass'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Pass' How to remove the ModuleNotFoundError: No module named 'Pass' error
ModuleNotFoundError: No module named 'Pass'
ModuleNotFoundError: No module named 'Pass'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Pass' How to remove the ModuleNotFoundError: No module named 'Pass' error
Passing Parameter - JSP-Servlet
, there's var answer. I need to pass this parameter back into the jsp part, how should i do
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
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
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
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
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
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
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
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
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
ModuleNotFoundError: No module named 'lib-parameter'
ModuleNotFoundError: No module named 'lib-parameter'  Hi, My... 'lib-parameter' How to remove the ModuleNotFoundError: No module named 'lib-parameter' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'magic_parameter'
ModuleNotFoundError: No module named 'magic_parameter'  Hi, My... named 'magic_parameter' How to remove the ModuleNotFoundError: No module named 'magic_parameter' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'parameter-sherpa'
ModuleNotFoundError: No module named 'parameter-sherpa'  Hi, My... named 'parameter-sherpa' How to remove the ModuleNotFoundError: No module named 'parameter-sherpa' error? Thanks   Hi, In your
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
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
Version of com.laamella>parameter-source dependency
List of Version of com.laamella>parameter-source dependency
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
PHP add parameter to url - PHP
PHP add parameter to url  need an example of parse_url in PHP. Thanks in advance
ModuleNotFoundError: No module named 'chrome-pass'
ModuleNotFoundError: No module named 'chrome-pass'  Hi, My Python... 'chrome-pass' How to remove the ModuleNotFoundError: No module named 'chrome-pass' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'lock-pass'
ModuleNotFoundError: No module named 'lock-pass'  Hi, My Python... 'lock-pass' How to remove the ModuleNotFoundError: No module named 'lock-pass' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'nedry-pass'
ModuleNotFoundError: No module named 'nedry-pass'  Hi, My Python... 'nedry-pass' How to remove the ModuleNotFoundError: No module named 'nedry-pass' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'panda3d-render-pass'
ModuleNotFoundError: No module named 'panda3d-render-pass'  Hi, My... named 'panda3d-render-pass' How to remove the ModuleNotFoundError: No module named 'panda3d-render-pass' error? Thanks   Hi
ModuleNotFoundError: No module named 'pass-cli'
ModuleNotFoundError: No module named 'pass-cli'  Hi, My Python... 'pass-cli' How to remove the ModuleNotFoundError: No module named 'pass-cli... to install padas library. You can install pass-cli python with following
ModuleNotFoundError: No module named 'pass-manager'
ModuleNotFoundError: No module named 'pass-manager'  Hi, My Python... 'pass-manager' How to remove the ModuleNotFoundError: No module named 'pass-manager' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pass-totp'
ModuleNotFoundError: No module named 'pass-totp'  Hi, My Python... 'pass-totp' How to remove the ModuleNotFoundError: No module named 'pass... have to install padas library. You can install pass-totp python with following
ModuleNotFoundError: No module named 'pytest-pass'
ModuleNotFoundError: No module named 'pytest-pass'  Hi, My Python... 'pytest-pass' How to remove the ModuleNotFoundError: No module named 'pytest-pass' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'Ri-PASS'
ModuleNotFoundError: No module named 'Ri-PASS'  Hi, My Python...-PASS' How to remove the ModuleNotFoundError: No module named 'Ri-PASS... to install padas library. You can install Ri-PASS python with following command
ModuleNotFoundError: No module named 'stretch-pass'
ModuleNotFoundError: No module named 'stretch-pass'  Hi, My Python... 'stretch-pass' How to remove the ModuleNotFoundError: No module named 'stretch-pass' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'chrome-pass'
ModuleNotFoundError: No module named 'chrome-pass'  Hi, My Python... 'chrome-pass' How to remove the ModuleNotFoundError: No module named 'chrome-pass' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'cisco_pass'
ModuleNotFoundError: No module named 'cisco_pass'  Hi, My Python... 'cisco_pass' How to remove the ModuleNotFoundError: No module named 'cisco_pass' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'geo-pass'
ModuleNotFoundError: No module named 'geo-pass'  Hi, My Python...-pass' How to remove the ModuleNotFoundError: No module named 'geo-pass... to install padas library. You can install geo-pass python with following

Ads