Link to home
Start Free TrialLog in
Avatar of asdflkjadsf
asdflkjadsf

asked on

compiling error (cannot reslove sysmbol)

I have get the following error when compiling.  Could someone provide me with a working solution?


FYI: The rt.exec only works when I put the variables into an array.


ThreeParams.java:43: cannot resolve symbol
symbol  : variable args
location: class ThreeParams
            FileOutputStream fos = new FileOutputStream(args[0]);
                                                        ^
1 error

import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class ThreeParams extends HttpServlet {
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Reading Three Request Parameters";
    out.println(ServletUtilities.headWithTitle(title) +
                "<BODY BGCOLOR=\"#FDF5E6\">\n" +
                "<H1 ALIGN=CENTER>" + title + "</H1>\n" +
                "<UL>\n" +
                "  <LI><B>param1</B>: "
                + request.getParameter("Name") + "\n" +
                "  <LI><B>param2</B>: "
                + request.getParameter("Text") + "\n" +
                "  <LI><B>param3</B>: "
                + request.getParameter("Date") + "\n" +
                "</UL>\n" +
                "</BODY></HTML>");

        String Date = request.getParameter("Date");
        String command = "/scripts/Script.sh";
        String Text = request.getParameter("Text");
        String cmd[] = new String[3];
        cmd[0]=command;
        cmd[1]=Text;
        cmd[2]=Date;
        System.out.println();
            FileOutputStream fos = new FileOutputStream(args[0]);
            Runtime rt = Runtime.getRuntime();
            Process proc = rt.exec(cmd);
        }
}
ASKER CERTIFIED SOLUTION
Avatar of Mayank S
Mayank S
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of asdflkjadsf
asdflkjadsf

ASKER

your right...the orginal file was not a servlet and I was passing an argument to it.  After removing the line above the class compiled
Great.