-2

I usually work with PHP but need to setup this JSP with a server that I am interacting with. Here is the code I am trying:

<%
String filename = request.getParameter("file");
filename = "C:\Tomcat 5.5\webapps\myapp\\" + filename;
out.print(filename);

ActiveXObject theObject = new ActiveXObject("Scripting.FileSystemObject");
File theFile = new theObject.GetFile(filename);

theFile.Move("C:\Tomcat 5.5\webapps\myapp\processed\\");

%>

The goal is to send in a request to http://www.thewebsite.com/myfile.jsp?file=x.txt and the JSP file should take x.txt and move it to the processed directory.

When I call this JSP file I get an error that says ActiveXObject cannot be resolved to a type ... so, I guess that I can't do it this way.

Is it possible to move a file using JSP?

Chris
  • 5,485
  • 15
  • 68
  • 130
  • JSP means **Java** Server Pages. You should read the **Java** api reference, instead of blindly trying to use objects that obviously could only exist on Windows. Java is a multi-platform language. http://download.oracle.com/javase/6/docs/api/. Also, read this post: http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files – JB Nizet Nov 04 '11 at 20:24

1 Answers1

0

This

ActiveXObject cannot be resolved to a type 

usually means that we need to import the class where ActiveXObject resides. In JSP use import directive to import the package you need.

<%@ page import="java.util.*" %>

Hope this helps!

Mechkov
  • 4,294
  • 1
  • 17
  • 25