Home Answers Viewqa Java-Beginners pass parameter - file

 
 


babu
pass parameter - file
1 Answer(s)      4 years and a month ago
Posted in : Java Beginners

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 Pages:
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
How to pass query as parameter? - JSP-Servlet
How to pass 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... not able to pass the value of qry1,qry2,qry3... Please help me to find the solution
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 value ... from SQL Out Parameter .In this Example we create a procedure 'abc
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 - 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
Passing Parameter - JSP-Servlet
, there's var answer. I need to pass this parameter back into the jsp part, how should i do
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
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
JPA Positional Parameter
JPA Positional Parameter       In this section, you will learn about the JPA Positional Parameter and how to use in your JPA application. JPA Queries are convenient to pass
JPA Named Parameter
JPA Named Parameter       In this section, you will learn how to use JPA Named Parameter in your jpa application. In JPA named parameter is used where you assign names
JSP:Passing query as parameter - Java Beginners
to pass the value of qry1,qry2,qry3... Please help me to find the solution
JSP:Passing query as parameter - Java Beginners
to pass the value of qry1,qry2,qry3... Please help me to find the solution
Pass values from form to form
request.getAttribute("parameter name").    Second, we can pass... Pass values from form to form       Java program to pass values from one form to another form
use data from database as hyperlink and pass the data in the hyperlink
use data from database as hyperlink and pass the data in the hyperlink  Hi Friends, I am using the data from database as hyperlink and pass the data as a parameter in the hyperlink to a servlet page. By using display table
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
Init Parameter
Init Parameter  How set Init Parameter in servlet
url parameter using retrive data from database in jsp
url parameter using retrive data from database in jsp  The user can create an event. In the create page, we have three buttons. Save as draft... technically pass the new id and displayed the latest values... That latest id Shown
Date Class with multiple numeric parameter constructor
Date class object and pass multiple numeric parameters as  the year, month...; </s:Application> In this example we have pass values 2010
Need Help-How to store input parameter in DB through Java Bean - JSP-Servlet
Need Help-How to store input parameter in DB through Java Bean  Hello Sir, I have a simple Issue but It is not resolve by me i.e input parameter are not store in Ms-Access. I store the input parameter through Standard Action
How to pass java.util.Properties in properties
How to pass java.util.Properties in properties  ... and properties. In this example we have used method init() with parameter... properties plus properties passed as parameter in init() method.  template.merge
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
pass method reference in java
pass method reference in java  How to pass method reference in Java
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
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
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
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
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
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
pass by value /reference - Java Beginners
pass by value /reference  hello sir/mam, i know pass by value is a primitive type in java. what about pass by reference in java ? .. For object type pass by value is used or pass by reference is used ? pls give me a example
Getting date by time
Getting date by time       In this example of creating date using the timestamp value. We can pass the timestamp value as constructor parameter while creating the object
Date Class with Single String parameter constructor example
parameterized constructor. If user pass a string parameter in the date class... object and pass a string parameter in this object to access the parameterized... the passing parameter. Output:- Download this code
onclick pass variable - JSP-Servlet
onclick pass variable  on button onclick event pass variable and print in textbox in same page... i want to pass value of variable at onclick event of button and also want to print it in textbox in same page....  Hi
JSP Session Parameter rewrite
JSP Session Parameter rewrite       In the section you will study about the session parameter... Parameter Rewrite</title> </head> <body> Last visit
Set Parameter - JSP-Interview Questions
Set Parameter  Hi, could someone please explain the process of setting parameter in the session from JSP with the help of code? Thanks!  Hi,In your JSP page use the Set Tag, and set the scope attribute
Pass the array please.. - Java Beginners
Pass the array please..  hi! i'm having problem with this programming..can anyone check where is my error.. Question: Write a program called... them in an array. When finished receiving the numbers, the program should pass
How to pass value of a link to a textfield
How to pass value of a link to a textfield  Dear Sir, in my project I'm initially making a value of the textfield as a link. Now, I want to pass the value of the link in the textfield after clicking the link and dont want to open
JSP get Parameter
JSP get Parameter          JSP get Parameter is used to return the value of a request parameter passed as query string and posted data which is encoded

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.