Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 4th, 2004, 09:05 AM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default SCRIPT WORKS WITH IE BUT NOT NETSCAPE!!!

Hello,
I have a very easy authentication script that works fine... but when there are errors (like incorrect user, config file does not exist...), it only works with IE and not with NETSCAPE!!!.
It is driving me crasy!!!
Help please!!
Here is part of the code (I have simplidfied it) and I have put traces so you can see why it does not work with Netscape.

With Explorer: I get the following alerts
Entering errorConfig
error is 2
exception is EXCEPTION


With Netscape: I only get;
Entering errorConfig
 ....
WHY!!!!
<html>
<head>
<title> Authentication Engine </title>
<script language=JavaScript>
javascript:window.history.forward(1);

<!--- oculta el script para navegadores antiguos
function errorConfig()
{
alert("Entering errorConfig");
var error=document.form2.error.value;
alert("error is "+error);
    ex=document.form2.ex.value;
alert("exception is "+ex);
document.location.href="login.jsp";
}

function result()
{
 var error=document.form1.error.value;
    message=document.form1.message.value;
 alert(error+":"+message);
 document.location.href="login.jsp";
}

function page_menu()
{
 document.location.href="menu.jsp";
}

function page_login()
{
 document.location.href="login.jsp";
}

// end hiding from old browsers -->
</script>
</head>
<%@page errorPage="errorPage.jsp"%>
<%@page language="java" %>
<%@page import="java.util.*" %>
<%@page import="java.io.*" %>
<%@ page import="javax.servlet.*, javax.servlet.http.*"%>
<%@ page import="javax.servlet.http.HttpServletRequest"%>
<%
int retCode=2;
System.out.println("login.jsp retCode="+retCode);
if (retCode != 0)
{
  // Config error => Goes to login.jsp
  //-----------------------------------
%>
  <form name=form2 method="post">
   <input type=hidden name="error" value=<%=retCode%>>
   <input type=hidden name="ex" value="Exception">
  </form>
  <script language="javaScript">errorConfig();</script>
<%
}

// Read password and uid
//----------------------
System.out.println("Read uid and password");
String uid=request.getParameter("uid");
String password=request.getParameter("password");
if ((uid != null) && (!uid.equals("")) &&
    (password != null) && (!password.equals("")))
{
  String[] res={"1", "NOT AUTHENTICATED"};
  System.out.println("authenticate.jsp - aut="+res[0]);
  if (!res[0].equals("0"))
  {
    // NOt authenticated ==> Goes to login.jsp
    //-----------------------------------------
%>
    <form method="post" name=form1>
       <input type=hidden name="error" value=<%=res[0]%>>
       <input type=hidden name="message" value="<%=res[1]%>">
    </form>
    <script language="javaScript">result();</script>
<%
  }
   // Go to menu.jsp
  //----------------
%>
   <script language="javaScript">page_menu();</script>
<%
}

// Go back to login.jsp (empty uid/password)
//-----------------------------------------
%>
<script language="javaScript">page_login();</script>
</html>




Reply With Quote
  #2 (permalink)  
Old October 4th, 2004, 06:00 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

This line:
javascript:window.history.forward(1);

should be, I think:

window.history.forward(1);

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
Reply With Quote
  #3 (permalink)  
Old October 5th, 2004, 03:52 AM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I changed it just in case but the problem is still there. I enter an incorrect username:
   - Explorer: goes to result() and fires the alert then goes to login.jsp
    - Netscape: goes to result() and does not fire the alert, then goes to login.jsp. It is as if the error or the message variables were not recognized by Netscape (putting an alert just after the error variable is not fired).


Reply With Quote
  #4 (permalink)  
Old October 5th, 2004, 01:22 PM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try using "Get" as your form method.

The "Get" method sends the input as an environment variable, whereas "Postt" sends it as a standard input string. Since your value is a JSP variable you may need to use "Get" rather than "Post".

I am not sure why this would work in IE and not Netscape, however.

Reply With Quote
  #5 (permalink)  
Old October 5th, 2004, 04:08 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Ulrich I believe that is irrelevant and incorrect. JSP can retrieve POST values.

elisabeth,

What does the pop-up in Explorer say? I bet it's only one word. You need to assign HTML attribute values surrounded in quotes, as it complies with the standards and should solve your problem.

So this...

<input type=hidden name="error" value=<%=res[0]%>>

...should be...

<input type='hidden' name='error' value='<%=res[0]%>'/>

Try it :-)

-Snib <><
http://www.snibworks.com
There are only two stupid questions: the one you don't ask, and the one you ask more than once ;)
Reply With Quote
  #6 (permalink)  
Old October 6th, 2004, 04:25 AM
Authorized User
 
Join Date: Feb 2004
Location: , , .
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I finally found what the problem was. ..... the <body> tag was missing! Explorer did not care about it but Netscape could not recognize the forms!!!!

Problem solved. Thank you all for your inputs.


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
script not working in mozilla, but works in IE grobar Javascript 1 April 9th, 2008 04:51 AM
script not working in mozilla but works in IE grobar Javascript How-To 0 May 26th, 2005 07:19 PM
Login.aspx works in netscape, but not IE cohansh1 BOOK: ASP.NET Website Programming Problem-Design-Solution 3 February 23rd, 2005 09:05 AM
Webuivalidation script doesnt work in netscape olambe BOOK: ASP.NET Website Programming Problem-Design-Solution 2 July 29th, 2004 08:30 AM
code works in IE but not netscape Toka1 Javascript How-To 2 November 27th, 2003 05:35 AM



All times are GMT -4. The time now is 08:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.