Java URL FAQ: Using Java, how can I encode a String that I want to safely pass in a URL to a servlet or CGI program running on a web server?
I created a JSP this morning that prints out the equivalent of most traditional CGI parameters. Sometimes I use these to debug a problem, other times I use them within JSP/servlet code for other non-debug purposes.
Here's the Java source code for my JSP CGI page, which I named
cgiParams.jsp. As you can see, most of these variables come from the JSP request object:
Here are a couple of quick Linux tips I put together. First, a Perl CGI program that prints every environment variable it knows.
Here's a sample Perl CGI program I wrote that prints out all of the environment variables it knows. I've found this program to be very useful when first installing a web server, or when debugging a problem with a web server or new environment.
Perl CGI environment variables - example program
Here's the code:
Below I've included a sample Perl CGI program that I use to edit some files on my web sites. I've modified the file a little bit for the purposes of this example, but it's essentially what I use.
Very Important: This program by itself is not secure in any way. It does not require a user login, etc. At the very least you will want to secure access to this program with an Apache htaccess configuration, or something similar on other Perl CGI web servers. This program is shown here for demonstration purposes only.