PDA

Click to See Complete Forum and Search --> : java app issues


Evan
Jan 23rd, 2004, 09:46 AM
I have this html page, and when I open it locally it works, but when I open it in the browser served by apache(working debian) it gives me these errors:

[Fri Jan 23 08:32:00 2004] [error] (13)Permission denied: exec of /usr/share/XIII/example1.html failed
[Fri Jan 23 08:32:00 2004] [error] [client 168.215.215.99] malformed header from script. Bad header=Launching... /usr/lib/apache-s: /usr/share/XIII/example1.html
eduffield@develop:~$


I tried this so far:
sudo chmod +X gen_validation.js
sudo chmod 777 gen_validation.js
sudo chmod +X example1.html
sudo chmod 777 example1.html

Premissions:
12 -rwxrwxrwx 1 office office 9282 Jan 23 08:35 gen_validation.js





<html>
<head>
<title>An Example of using the general validation function </title>
</head>
<SCRIPT language="JavaScript1.2" src="gen_validation.js"></SCRIPT>
<body>
<P align=center>
<SCRIPT language="JavaScript1.2">
var arrFormValidation=
[
[//2343
["maxlen=25",
"First Name should be 25 characters max(Consider changing your Name !)"
],
["minlen=1",
"Please Enter your First Name ( Contact support if you don't have one! )"
],
["alpha",
"Only alphabetic characters expected in your First Name"
]
],
[//234
["maxlen=25"],
["minlen=1"],
["alpha"]
],
[//234
["maxlen=50"],
["minlen=1"],
["email"," Please enter the correct Email address"]
],
[//234
["numeric"]
],
[//234
["maxlen=500"]
],
[//Country
["dontselect=0",
"Please Select your Country [ if you are not from Mars :) ]"
]
]
];
</SCRIPT>
<form action="" onSubmit="return validateForm(this,arrFormValidation);">
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td align="right">Frst Name</td>
<td><input type="text" name="FName"></td>
</tr>
<tr>
<td align="right">Eail</td>
<td><input type="text" name="Email"></td>
</tr>
<tr>
<td align="right">Lst Name</td>
<td><input type="text" name="LastName"></td>
</tr>
<tr>
<td align="right">Pone</td>
<td><input type="text" name="Phone"></td>
</tr>
<tr>
<td align="right">Adress</td>
<td><textarea cols="20" rows="5" name="Address"></textarea></td>
</tr>
<tr>
<td align="right">Country</td>
<td>
<SELECT name="Country">
<option value="" selected>[choose yours]
<option value="008">Albania
<option value="012">Algeria
<option value="016">American Samoa
<option value="020">Andorra
<option value="024">Angola
<option value="660">Anguilla
<option value="010">Antarctica
<option value="028">Antigua And Barbuda
<option value="032">Argentina
<option value="051">Armenia
<option value="533">Aruba
</SELECT>
</td>
</tr>
<tr>
<td align="right"></td>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</P>
</body>
</html>

Evan
Jan 23rd, 2004, 11:18 AM
You cant link to a JS file from perl I guess.. So you stick the JS in the header.

I found this code that worked perfectly



<!-- TWO STEPS TO INSTALL BASIC VALIDATION:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: wsabstract.com -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function checkrequired(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,8)=="required") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
}
}
}
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("Please make sure the "+shortFieldName+" field was properly completed.");
return false;
}
else
return true;
}
// End -->
</script>

<!-- STEP TWO: Copy this code into the BODY of your HTML document -->

<center>
<form onSubmit="return checkrequired(this)">

<input type="text" name="requiredname">
<br>
<input type="text" name="requiredemail">
<br>
<select name="requiredhobby">
<option selected>Pick an option!
<option>1
<option>2
<option>3
</select>
<br>
<textarea name="requiredcomments"></textarea>
<br>
<input type=submit value="Submit">
</form>
</center>

<!-- The first option in your pulldown menus must be set to 'selected' !! -->

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 1.41 KB -->

CornedBee
Jan 23rd, 2004, 12:01 PM
1) This is a apparently a CGI question.
2) Even if it were about JavaScript, it would not belong in the Java forum.

3) You can't execute HTML as CGI. Or not that simple. But your specific problem might be solved by putting
Content-type: text/html


at the top of your file. Note the extra newline, it's important.

Evan
Jan 23rd, 2004, 04:47 PM
I thought it was a javascript error, because that is what it named at the problem in the error.log. thats why I put it here.

Thanks.

CornedBee
Jan 24th, 2004, 04:04 AM
No, it calls it a "script error", nowhere does it say JavaScript. It just means that the server thinks there's an error in your CGI script, while in truth there is no CGI script, just a plain HTML file, which means that you have either renamed a html file to .cgi or you have some setup problem with your server.

Evan
Jan 24th, 2004, 11:29 AM
but see to fix the problem, all I had to do was put the JS file into the HTML file. So how do you account for that?

CornedBee
Jan 24th, 2004, 04:59 PM
Maybe it was the JavaScript file that was interpreted as CGI?

No, apparently not.

Anyway, JavaScript is executed on the client, so no JavaScript error will ever show up in your server logs.

Evan
Jan 25th, 2004, 12:33 PM
If the server cant get the correct premissions to even include a JS script it would show up in the error.log wouldnt it?

[Fri Jan 23 08:32:00 2004] [error] (13)Permission denied: exec of /usr/share/XIII/example1.html failed
[Fri Jan 23 08:32:00 2004] [error] [client 168.215.215.99] malformed header from script. Bad header=Launching... /usr/lib/apache-s: /usr/share/XIII/example1.html


and it would only say Bad header=Launching... permission denied when the JS script was included.

CornedBee
Jan 25th, 2004, 12:38 PM
[client 168.215.215.99] malformed header from script.
This one's definitly a CGI error. The client complains to your server that the header sent by the CGI is invalid.

At least that's what I think, I'd need the access to the server to experiment to be sure.

Including a JavaScript file only requires read access, but the log entry says that it can't execute.

Where exactly in your directory structure do these files reside, and can you post your server config?

Evan
Jan 27th, 2004, 11:11 AM
my dir structure is this


XIII\ <-perl
XIII\templates <-htm that feeds to perl

Evan
Jan 27th, 2004, 11:12 AM
hmm thats interesting. maybe apache isnt setup to execute .JS, thats why it worked in the HTML file

Travis G
Jan 27th, 2004, 11:50 AM
Some people just fail to get this:

Java != JavaScript

And CornedBee is right, this smells like a CGI problem, not a JavaScript problem. And you don't appear to have any Java within a 10 gig partition.

Curse Netscape for renaming LiveScript and riding Sun's dusty coat tails. A PHB decision if there ever was one.

Evan
Jan 27th, 2004, 12:29 PM
heh. interesting