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



Home Answers Viewqa Java-Beginners pass parameter - file

Have Programming Question? Ask it here!
 
 
 


babu
pass parameter - file
1 Answer(s)      5 years and 3 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 value ... 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 - 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 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
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
Is Java pass-by-reference?
Is Java pass-by-reference?  Is Java pass-by-reference
pass method reference in java
pass method reference in java  How to pass method reference in Java
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
JPA setParameter (Named Parameter)
JPA setParameter (Named Parameter)   ... API's method setParameter as a named parameter. JPA Query API's supports two... Here we are going to develop an application for using the named parameter
Set Date Parameter to get specific value
Set Date Parameter to get specific value  How to set the date parameter or fetch a specific data records based on date? For example fetching the two or three months old records
How do you pass a variable by value?
How do you pass a variable by value?  How do you pass a variable by value
how to pass command line arguments in ant
how to pass command line arguments in ant  How to pass runtime values ie commandline arguments to a program written in java using ant tool
Parameter month I Report - Java Beginners
Parameter month I Report  hy, I want to ask about how to make parameter in I Report, parameter is month from date. How to view data from i report use like "12/2008". Thank's  Hi friend, Plz give details
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
Call-time pass-by-reference has been removed in
Call-time pass-by-reference has been removed in  HI, What is the solution for the error: Call-time pass-by-reference has been removed in Thanks
pass radio button values to next page
pass radio button values to next page  how to pass selected radio button values which coming from mysql database to next page using php. Please show me with examples
Java Pass Value Example
Java Pass Value Example       Pass value from JSP to JavaScript We can also pass the value from a JSP page to the java script as we have done in our
 

 

 

DMCA.com