Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

File Select always returns null

843830Jan 30 2010 — edited Feb 1 2010
Hello

I am trying to return the name of the file that is selected from the file selector,

when i run the code it just returns null. the code is below could someone please help me.

{code/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package org.mypackage.hello;

/**
*
* @author
*/
public class NameHandler
{
private String name;
private String sName;
private int age;
private String strFile;

public NameHandler()
{
name = null;
}

/**
* @return the name
*/
public String getName() {
return name;
}

/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}

/**
* @return the age
*/
public int getAge() {
return age;
}

/**
* @param age the age to set
*/
public void setAge(int age) {
this.age = age;
}

/**
* @return the sName
*/
public String getsName() {
return sName;
}

/**
* @param sName the sName to set
*/
public void setsName(String sName) {
this.sName = sName;
}

/**
* @return the strFile
*/
public String getStrFile() {
return strFile;
}

/**
* @param strFile the strFile to set
*/
public void setStrFile(String strFile) {
this.strFile = strFile;

}

}

}<%--
Document : index
Created on : 13-Jan-2010, 19:10:14
Author :
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Morgages</title>
<img src="http://activerain.com/image_store/uploads/4/6/4/4/3/ar116674133034464.jpg" width="550" height="150" alt="mr-t"/>
<style>
ul
{
list-style-type:none;
margin:0;
padding:0;
}
</style>
<ul><style type="text/css">
ul
{
list-style-type:none;
margin:0;
padding:0;
}
li
{
display:inline;
}
</style>
<li>Home</li>
<li>Response</li>
</ul>
</head>
<body>
<h1 style="font-family:times;color:black">Entry Form</h1>

<HR>
<BR>
<form name="Name Input Form " action="response.jsp">
Name:
<input type="text" name="name" value="First Name" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;"/>
<input type="text" name="sName" value="Surname" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;"/><br><br>
Age :
<input type="text" name="age" value="Enter Age" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;"/><br><br>
File :
<input type="file" name="strFile" value="c:\" /><br><br>
<input type="submit" value="O.K." />
</form>
</body>
</html>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 1 2010
Added on Jan 30 2010
1 comment
78 views