This is my Login Action class and the following error is comming kindly help me out to resolve this error , thanku so much in advance
**The Error I am getting is**
LoginForm.java:46: cannot resolve symbol
symbol : class ActionError
location: class com.MyPack.Datamatics.LoginForm
ae.add("username" , new ActionError("errors.username.req
uired") );
^
LoginForm.java:50: cannot resolve symbol
symbol : class ActionError
location: class com.MyPack.Datamatics.LoginForm
ae.add("password" , new ActionError("errors.password.req
uired") );
^
UploadAction.java:37: cannot resolve symbol
symbol : method read (byte[],int,int)
location: class java.io.OutputStream
temp = outputStream.read(buffer, 0, 8192);
^
3 errors
----------------------------------------------------------------------------------------------------------
My source code for login Action class is belowpackage com.MyPack.Datamatics;
import javax.servlet.http.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action.*;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError.*;
//import java.util.*;
//import java.io.*;
public class LoginForm extends ActionForm
{
private String username=null;
private String password=null;
public void setUserName(String username)
{
this.username=username;
}
public String getUserName()
{
return username;
}
public void setPassword(String password)
{
this.password=password;
}
public String getPassword()
{
return password;
}
public void reset(ActionMapping am,HttpServletRequest req)
{
this.username="";
this.password="";
}
public ActionErrors validate(ActionMapping am, HttpServletRequest req)
{
ActionErrors ae = new ActionErrors();
if ( (username==null) || (username.length()==0))
{
ae.add("username" , new ActionError("errors.username.required") );
}
if( (password==null) || (password.length()==0))
{
ae.add("password" , new ActionError("errors.password.required") );
}
return ae;
}
}
My source code for UploadAction is
package com.MyPack.Datamatics;
import javax.servlet.http.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
public class UploadAction extends Action
{
public ActionForward execute(
ActionMapping am,
ActionForm af,
HttpServletRequest req,
HttpServletResponse res) throws Exception{
UploadForm myForm = (UploadForm)af;
// Process the FormFile
FormFile myFile = myForm.getTheFile();
String contentType = myFile.getContentType();
String fileName = myFile.getFileName();
int fileSize = myFile.getFileSize();
String data="";
try{
java.io.InputStream fileData = myFile.getInputStream();
String path="E:/store";
File f = new File(path);
java.io.OutputStream outputStream = new FileOutputStream(f+"/"+fileName);
int temp = 0;
byte[] buffer = new byte[8192];
temp = outputStream.read(buffer, 0, 8192);
// while ((temp) != -1) {
//outputStream.write(buffer, 0, temp);
// }
outputStream.close();
data = "file has beeb written to E:/store" + fileName;
fileData.close();
}
catch (FileNotFoundException fnf)
{ System.out.println("Cannot Found the file");
}
System.out.println(data);
System.out.println("contentType: " + contentType);
System.out.println("File Name: " + fileName);
System.out.println("File Size: " + fileSize);
return am.findForward("success");
}
}
Thanks