From the result, I'm going to extract the path using Perl's substr and index functions.
I will then use the result and append it to the filename of a new jsp file in that same path. Then I can have, http://host/contextPath/result.jsp.
I'd be happy to answer any clarifications since I'm not sure if I explained that correctly.
I don't know the how the reply helpful to you. But I hope you will get a bit. Below I place the sample code for you. For better understand purpose do the below steps and execute the program
1) Create path like 'e:\dani\delim\path\example'
2) Place the perl program
3) Create the file like 'e:\dani\japh.pl'
4) Run the perl file.
From the result, I'm going to extract the path using Perl's substr and index functions. From the result, I'm going to extract the path using Perl's substr and index functions.
No need to use substr function here. Better you have use the 'File::Basename' module. That gives the base directory and file name.
The 'abs_path' gives the absolute path of the given file.
use Cwd 'abs_path';
# Get the Absolute path a particular file
my $path = abs_path("../../../japh.pl" );
print "\nabs path : ", $path;
# Get the base directory of the file
my $base_dir = dirname($path);
print "\nbase path : ", $base_dir;
# Append another one file to the base dir
my $another_file = "$base_dir/myfile";
print "\nAnother file : ", $another_file;