How to pass a command line argument to a jsp file...

Hi guys,
I'm writing a jsp file in which I have some java codes. I want to pass some command line arguments to that jsp file. In other words, I have some files located somewhere on my C drive and I want to pass the path to these files to my jsp file. How can it be done? I have never done before.
Any suggestion will be very hepful...
Thanks....

I dont know if I truly understand your problem...
For instance, when you place the url of your jsp you can add, at the end some parameters. For example:
http://myserver/myapp/myjsp.jsp?MyParameter=C:\Temp\JavaTutorial.html
In your JSP, you can place this code on a scriplet to get the value:
String path = request.getParameter("MyParameter");
Hope it helps.

Similar Messages

  • How to pass a command line argument to the sequence?

    Hi,
    My GUI is written in VB.NET. I can read the command line argument in the GUI, using: Me.AxApplicationMgr.CommandLineArguments(). But I don't know how to pass it on to my sequence file which the GUI invokes. How do I read the command line argument from the sequence file?
    My purpose, is to have the same basic sequence execute different subsequences depending on starting conditions...
    I am using TestStand 3.0 with a VB.NET GUI, on Windows XP.
    I'd appreciate any help on the subject.
    Alan

    Hi Alan,
    One obvious way would be to add parameter(s) to the MainSequence and then modify the process model sequence file to use the new parameter(s) in the step "MainSequence Callback"  in either Single Pass or Test UUTs but I wouldn't recommend this approach.
    The sequence file to be run via the entry point can be found at "RunState.ProcessModelClient" and the lookup string to the MainSequence would be "RunState.ProcessModelClient.Data.Seq["MainSequence"] or .Seq[0] .
    Therefore you could quite easy use the SetVal method to setup a Local variable in the MainSequence of your Sequence File to receive the command line string.
    Also you could do this without altering the Process Model Sequence File by using the Callback Sequence ProcessSetup in your Sequence File.
    As an example.
    You have a string in your Locals of MainSequence called CmdLineStr.
    If you add the Callback Sequence ProcessSetup to your SequenceFile, then add an ActiveX Automation Adapter step which is setup for a PropertyObject and the reference is RunState.Caller.RunState.ProcessModel.Data.Seq[0].Locals.CmdLineStr.
    There is an extra RunState.Caller to the lookup string, that's because I am doing the work in a SubSequence of Entry Point Sequence.
    The method to use is SetValString and the parameters of the PropertyObject will be
    lookupString = ""
    options = 0 or 1
    newValue = where evey you have stored you command line string.
    Now when you run your sequence file you will find that the Locals.CmdLineStr will contain your parameter string.
    Hope this is of help to you.
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • Pass dynamic Command line arguments

    Hi,
    I tried to pass dynamic command line argument to Web start using the method :
    "javaws URL -D foo -D bar"
    as explained in the "Unofficial JWS/JNLP FAQ" that " You can pass your own system properties to your app using -D switch ....", but I got the following error at the start;
    error occurred while launching/running the application.
    Category: Invalid Argument error
    Too many arguments supplied: {http://...URL/my.jnlp, -Did=123 }
    p.s. I already added the"<property name='' value=''/> in the <resourse>, and modified the main class to get the parameter using System. getProperty();
    Did anyone try to this method before? What's wrong of this?
    Thanks in advance for your help.

    Thanks.
    here below is the jnlp file:
    <jnlp spec="1.0+" href="$$name" codebase="$$codebase">
    <information>
    <title>GUI Application</title>
    <vendor>PS</vendor>
    <description>PS GUI WebStart Version</description>
    <icon href="logo.jpg" />
    <offline-allowed />
    </information>
    <resources>
    <j2se version="1.3" />
    <jar href="lib/gui.jar" />
    <property name="id" value="zbc" />
    <jar href="lib/classes12.zip" />
    <jar href="lib/j2ee.jar" />
    <jar href="lib/jaas.jar" />
    <jar href="lib/jce1_2_1.jar" />
    <jar href="lib/jdom.jar" />
    <jar href="lib/xerces.jar" />
    <jar href="lib/local_policy.jar" />
    <jar href="lib/log4j.jar" />
    <jar href="lib/orion.jar" />
    <jar href="lib/sunjce_provider.jar" />
    <jar href="lib/US_export_policy.jar" />
    </resources>
    <security>
    <all-permissions />
    </security>
    <application-desc main-class="GUIFrame">
    </application-desc>
    and in the main class "GUIFrame", i use System.getProperty("id") t get the parameter, if I hardcode the value of the "id" in this jnlp file and use javaws URL, everything's fine, but not the "javaws URL -Did=value" which will return the error as mentioned.
    Thanks again for your help.

  • Pass the command line argument (argc and argv) to a LabVIEW built shared library.

    Hello,
    I have successully use this trick to build a LabVIEW application that runs on Linux without X Display.
    http://digital.ni.com/public.nsf/allkb/5D6EC36DCF43343786257449006919E6
    I'd like to know if it's possible to pass the command line arguments ( ./TEST A B C D) directly into the shared library without having to pass the arguments using a array of strings which would require to write code using DSNewHandle, DSSetHandleSize, extract the arguments and ..... (I'm not proficient in C, but if I don't have a choice I will do it and improve my C skills).
    int main(int argc, char *argv[])
            Test(argc, argv);
            return 0;
    Thanks,
    Michel
    Solved!
    Go to Solution.

    Well, you can always flatten it back into a space separated single string and pass it like that. Basically reverse what the OS does when it calls your main function with the command line parameters. And while the first element in the array is always the program name itself you can just skip that here, but then format all the rest into a single string.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to hide the command line arguments from solaris process

    Hi All,
    When I execute a JAR application from a java file using the Runtime.getRuntime, the command line arguments (user ID and Password details) which I passed for executing the application displayed on Solaris process (ps -ef).
    Could anybody please help me, how can I hide either the process or the command line arguments from the Solaris process?
    I cannot pass any asterix or any special character in place of password, because the executing application doesn't have any functionality to retreive the password which send as asterix characters.
    Please help me
    SumodeV

    Thanks for all the response.
    I have created a design and implement the functionality which executes the JAR application in Solaris environment without showing any details in the process details.
    I have used the Java Reflection method, which invokes the JAR application. I am sharing the details here for all those who looking for it.
    1, Inside the Customer application [Jar File is running for it], collect the necessary session details [Using System.get property method]
    2, Create an independent Java file, which should be used to invoke the JAR application
    3, Create the ProcessBuilder object and use a command - execute the Java file [a wrapper code] using normal Java command
    4, Pass the necessary session details to the ProcessBuilder using the environment() function.
    5. Collect the environment values in the independent Java file (Which was invoked by ProcessBuilder) and set details for its environment using System.setProperty.
    6, Use reflection technique to invoke the JAR plugin [which you want to run]. You can use the standard Java functionality to read the MANIFEST file of JAR and load the main class using URLClassLoader.
    7, Invoke the main method of the JAR file, which run the JAR application in Solaris window
    This solution will make sure that the process cannot display any session details in the Solaris Environment.
    Note: Use String[] array while create the command. Otherwise the JAR application cannot pop-up.
    Regards
    Sumode

  • How to run a command line argument

    i want to run a command line argument, say for eg......i want to execute the "dir" command on the dos prompt and capture the output.
    how can i do this.
    actually i want to capture the output of the ping command and write it to a file. can any body plsssssss help

    This command runs a ping to "address" and writes the output back to the command line. To capture it, just put strings into an array or do whatever you want with it. If you want to wait until the program completes before reading its input, use p.waitFor().
    Process p = Runtime.getRuntime().exec("ping " + address);
    BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String currLine = null;
    while((currLine = in.readLine()) != null)
      System.out.println("ping: " + currLine);
    [/code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Passing * as command line argument

    I need to take some arguments from cmd in my java program which need to be of this form:
    java myprogram 4574 10 *
    Everything else works fine but when it comes to the asterisk (*) it is replaced by the file list and the args[] in my program becomes
    4574
    10
    myprogram.class
    myprogram.java
    123.txt
    Now i know that instead of giving * if i give "*" the program would be fine.... but is there any way to pass only * (without quotes) in arguments and get the * character in my args array.

    Compiled with the free command-line Borland compiler and run from cmd:
    #include <stdio.h>
    void main(int argc,char *argv[]) {
    int i;
    for(i=0;i<argc;i++)
    printf("%d [%s]\r\n",i,argv);
    C:\temp\efemer34\xx>a *
    0 [C:\temp\efemer34\xx\a.exe]
    1 [*]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Test Stand: How does parameter's value is passed as command line argument?

    Hi All,
    This is my 1st Q on this board.
    I'm using Test Stand Sequence to call a subsequence where I call an executable file and passing few arguments to it.
    SuperSequence.seq => SubSequence.seq
    In SuperSequence.seq I have 3 parameters and their values are specified
    Parameters
    Name      Type    Value
    ==============================
    Name      string    "Nirvana"
    Address  string    "London"
    Tel           Number "123456"
    In SubSeq.seq I call and EXE with following parameters
    Executable Path Name: myApp.exe
    Argument Expressxion:  "Parameters.Name  Parameters.Address  Parameters.Tel"
    In the application I receive parameter names instead of their values?
    E.g. I recevie Parameters.Name  Parameters.Address  Parameters.Tel in myApp.exe as arguments.
    How do I make the values to be passed to myApp.exe instaed of parameter names?
    Cheers
    Nirvana

    Hi,
    You have to make a string containing the arguments that you require
    Try the following expression
    Parameters.Name  + " " + Parameters.Address + " " +Str( Parameters.Tel)
    Regards
    Ray Farmer
    Regards
    Ray Farmer

  • How to count Command-Line Arguments ?

    How do you count Command-Line Arguments ?
    For example,
    java program argument1 arguement2
    I would like to be able to count how many arguements the user inputed
    It should result as 2 for the bold line above
    Thank you for your help

    public static void main(String[] args) {
        int numArgs = args.length; // args holds argument1 and argument2
    }

  • Solaris 10 command-line argument to /etc/init.d/apache

    Does anyone know how to control the command-line argument sent to /etc/init.d/apache that ships with Solaris 10 11/06?
    # svcs *\apache\*
    shows Solaris is running Apache 1.3 as a legacy service with the FMRI lrc:/etc/rc3_d/S50apache.
    According to Sun documenation ("How to Modify a Command-Line Argument for an inetd Controlled Service" <http://docs.sun.com/app/docs/doc/817-1985/6mhm8o5ss?a=view>), one should be able to make desired changes using the inetadm command. The problem is,
    # inetadm
    doesn't show anything at all related to apache or httpd. I thought about changing the inittab file, but Sun's comments in the file pretty much say "hands off."
    I'm trying to have Apache SSL enabled at boot time (i.e. argument startssl instead of start). As a temporary hack, I've edited apachectl so that the "start" argument is processed like "startssl."
    Thanks!

    tmilbank wrote:
    Does anyone know how to control the command-line argument sent to /etc/init.d/apache that ships with Solaris 10 11/06?
    # svcs *\apache\*
    shows Solaris is running Apache 1.3 as a legacy service with the FMRI lrc:/etc/rc3_d/S50apache.
    According to Sun documenation ("How to Modify a Command-Line Argument for an inetd Controlled Service" /etc/rc3 services have nothing to do with inetd.
    The script is running from the above file (/etc/rc3.d/S50apache).
    That's normally apache 1.x. If you do 'svcs -a', you'll see disabled services as well, which will include the apache 2.x server.
    <http://docs.sun.com/app/docs/doc/817-1985/6mhm8o5ss?a=view>), one should be able to make desired changes using the inetadm command. The problem is,
    Neither version of apache runs from inetd. Are you interested in apache 1.x or apache 2.x?
    Darren

  • Help with char and command line arguments

    I am writing a program that takes 2 command line arguments (such as 4 b, or 3 4, etc.). It uses the first argument to determine the height of a triangle (how many rows high), and the second is the character with which the triangle is drawn.
    My problem is I tend to code backwards - go for the bigger part and then figure out the smaller things. So, I've written a program that prints out this triangle, BUT I can't figure out how to get the command line arguments into it properly. A number works fine because I can:
    size = Integer.parseInt(args[0]);
    but what do I do if the second argument is a character? Args is a String array (I've been fighting with it for the past 4 hours, so I KNOW its a String array) - so how can I get a char to be read as args[1]?
    Here is my code before adding in the second argument (the char):
    public class Triangle
    public static final void main(String[] args)
    int size;
    if (args.length > 0)
    try
    size = Integer.parseInt(args[0]);
    catch(NumberFormatException e)
    System.out.println("Input Error");
    createFilledTriangle(size);
    System.out.println();
    public static void createFilledTriangle(int size)
    int i = 0;
    int j = 0;
    for(i = size, j = 1; i > 0; i--, j +=2)
    printChar(" ", i);
    printChar("*", j); <-----Instead of using * I want to use the second command line arg
    System.out.println();
    private static void printChar(String str, int total)
    for(int i = 0, i < total; i++)
    if(i%2 == 1)
    System.out.print(str);
    else
    System.out.print(" ");
    Thank you for any help in advance!

    I was sure i send it the other day, i probably send it to the wron guy.
    This will give you more idea about drawing.
    import java.awt.*;
    import java.awt.event.*;
    public class Args extends Frame
         Panel panel = new Tpan();
         int   arg1;
         char  arg2;
    public Args(int a1, char a2) 
         super();
         arg1 = a1;
         arg2 = a2;
         setBounds(1,1,600,400);     
         setLayout(new BorderLayout());
         addWindowListener(new WindowAdapter()
         {     public void windowClosing(WindowEvent ev)
              {     dispose();
                   System.exit(0);
         add("Center",panel);
         setVisible(true);     
    public class Tpan extends Panel
    public Tpan()
    public void paint(Graphics g)
         super.paint(g);
         g.setColor(Color.blue);
         g.drawLine(120,110-arg1,80,110);
         g.drawLine(120,110-arg1,160,110);
         g.drawLine(80,110,160,110);
         g.setColor(Color.red);
         g.drawLine(120,110-arg1,120,110);
         g.setColor(Color.black);
         g.drawString(""+arg2,116,110-arg1/2+10);
    public static void main (String[] args) throws InterruptedException
    // get the 2 arguments from the args insread of a1= , a2=
         int  a1  = 60;
         char a2 = 'a';
         new Args(a1,a2);
    Noah
    import java.awt.*;
    import java.awt.event.*;
    public class Args extends Frame
         Panel panel = new Tpan();
         int arg1;
         char arg2;
    public Args(int a1, char a2)
         super();
         arg1 = a1;
         arg2 = a2;
         setBounds(1,1,600,400);     
         setLayout(new BorderLayout());
         addWindowListener(new WindowAdapter()
         {     public void windowClosing(WindowEvent ev)
              {     dispose();
                   System.exit(0);
         add("Center",panel);
         setVisible(true);     
    public class Tpan extends Panel
    public Tpan()
    public void paint(Graphics g)
         super.paint(g);
         g.setColor(Color.blue);
         g.drawLine(120,110-arg1,80,110);
         g.drawLine(120,110-arg1,160,110);
         g.drawLine(80,110,160,110);
         g.setColor(Color.red);
         g.drawLine(120,110-arg1,120,110);
         g.setColor(Color.black);
         g.drawString(""+arg2,116,110-arg1/2+10);
    public static void main (String[] args) throws InterruptedException
    // get the 2 arguments from the args insread of a1= , a2=
         int a1 = 60;
         char a2 = 'a';
         new Args(a1,a2);

  • How to Pass Command line arguments to an exe created in LV8.0

    Hi Friends,
    I have Created an exe in LV8.0, which accepts the Folder path as input and executes.
    I want to call this exe passing the parameter (i.e folder path in my case)  from the command line argument. How to pass arguments to the exe ?
    Generally we may be having different types of input parameters to a vi like numeric control, string, boolean etc..If we create an exe that needs three input parameters among which one is boolean, other is string and third is a numeric value.
    How to pass these different types of input controls to the exe as parameters in command line at the same time?
    Thanks and Regards,
    SODLB

    I don't have any experience with the 8.x application builder, but the 7.x one has a checkbox for passing the arguments to the executable.
    As for reading them, there should be an example in the example finder (Help>>Find Examples) which shows how to do this. If you want to pass multiple parameters, I suggest you use a structure similar to NAME=VALUE, so that you can parse each element to find the = and then use a case structure to decide what to do with the parameters. This allows your users to enter or not enter any of the switches.
    Try to take over the world!

  • How to pass command line arguments to Web Start appclient?

    Hi,
    I would like to pass arguments to appclient, but "javaws" unable to do that.
    Do I have to overwrite the JNLP? I use Sun Appserver 9.0, it creates JNLP on the fly!!!
    Please help, thanx!
    MB

    Hi, MB.
    If you are talking about the automatic Java Web Start support for launching app clients in GlassFish, you can pass the equivalent of command line arguments using the query string of the URL you use to launch the app client.
    Briefly, use
    http://host:port/client-path?arg=first-arg&arg=second-arg& ...
    specifying the argument values in the order that you want them passed to the client.
    The GlassFish server will do the right thing and generates the correct JNLP so your arguments are passed to the app client.
    The GlassFish developer's guide http://glassfish.dev.java.net/nonav/javaee5/docs/AS91DG.pdf discusses this and all aspects of the Java Web Start support. You can also take a look at this blog entry http://blogs.sun.com/quinn/entry/command_line_arguments_and_properties that focuses on how to pass arguments.
    Since this technique deals with argument passing in the URL, it works no matter how you launch the app client: a URL in a browser, the javaws command, etc.
    - Tim

  • How to pass command line arguments to JWS app

    Hi,
    I want to pass command line arguments to my JWS application. However those arguments are dynamic (eg the username of the user who launched the app) and thus I can not use the argument tag of JNLP file. So what do I need to do in this case?
    Thanks.

    Well, if it's the username on your server systems you should probably include it in the jnlp: can pass it in the url, write once and remove jnlp href attribute, etc.., etc.. (a quick tour of this forum should suffice).
    If it's the OS username you should be able to retrieve it through system properties.
    Whatever it is, passing dynamic arguments means launching javaws through a shell or a shell script (bat if running on windows), so you won't be able to launch through autogenerated desktop and menu shortcuts.
    Anyway, you have two solutions:
    Clean one: associate an extension to your app and write those infos in a file named after that extension.
    Dirty one (always seen it work, but there's no warranty): javaws -open whateverParamYouLike yourAppURL.jnlp, will pass to your main method '-open' as args[0] and '+whateverParamYouLike+' as args[1]. I gotta admin I used it, but I had the most peculiar reason (my app needed another instance on a different JRE aware of being a secondary instance at startup time).
    Bye.
    PS: I'd really love dukes ;-)

  • How to run command line argument programe

    Hi guys, I am doing pass command line argument programe in java but I don't know how to run this programe. Path for this programe in my my computer is C:\Users\Desktop\Mainjava\mycode\CommandProgjava*
    {code/}
    public class CommandProg
    public static void main(String[] args)
    System.out.println("d");
    for (int i = 0; i < args.length; i++)
    System.out.println(args);
    {code/}
    Where i need to go and what command i need to give so i can execute this programe(I am using window vista). I only know i have to give
    this command some where CommandProg arg1 arg2 arg3 arg4. Output should be
    Output:
    arg1
    arg2
    arg3
    arg4
    Please help me, Thanks in advance.
    Edited by: JayVirk on Dec 30, 2007 11:33 AM

    Jay,
    Your question isn't very clear, hence Joerg's well meaning but irrelevant advise.
    Do you mean:
    I've written a simple program in java which echos
    it's command-line arguments to back to the console.
    Here's my code:
    package forums;
    public class ArgsEchoer
      public static void main(String[] args) {
        for (String arg : args) {
          System.out.println(arg);
    But can't figure out how to compile and run the program.
    I'm using winblows shista, and it's cr@p.
    Please help me, Thanks in advance.So... where are you at? Have you installed the JDK (java development kit)? Which version? Is your path set? Is your classpath set?
    Start here: http://java.sun.com/developer/onlineTraining/new2java/

Maybe you are looking for