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);
        }
}
Java

Avatar of undefined
Last Comment
Mayank S
ASKER CERTIFIED SOLUTION
Avatar of Mayank S
Mayank S
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
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
Avatar of Mayank S
Mayank S
Flag of India image

Great.
Java
Java

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

102K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo