Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Famous "Object expected"error,Wishing Browser Independent

 
vaibhav punekar
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all Java gurus,
u all might have faced the famous javascript error ie"Object expected" and similarly might have faced browser dependency problem.I hope these problems would be sorted out soon so that we developers are relieved of the load of debugging javascript.
I request you all to please start a list mentioning the circumstances in which 'this' error occurs and the possible remedy over it.So that it will be useful to all developers.Do you all agree guys?Thanks and expecting a huge list.
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There can be such a huge discrepencies between Netscape and IE's javascript calls, and even more when you go from 2.0 to 5.0 browsers. I think most of us see it as just a pain that we have to deal with because there is no way that it will ever be the same. So knowing the differences is the key. Or what I do is not memorize the differences, but now how to fix it when it comes up. Let me tell you, my debugging skills sure has improved.
Bill
 
vaibhav punekar
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I m currently getting object expected error in the following code.Is it because I m using the the variables defined outside the javascript fn.
I m not able to fix it.Can anybody fix it please?Thanks.
-----------------------code----------------------------
out.println("<td><input type='button' value='Submit' onClick='return validation(req)'></td>"); //error here
out.println("<td><input type='reset' value='Cancel'></td>");
out.println(" </tr>");
out.println("</form>");
out.println("</table>");
out.println("</center>");
out.println("</div>");
out.println("</body>");
out.println("<script language='javascript'>");
out.println("<!--");
out.println(" function validation(HttpServletRequest req){ ");
out.println("if(document.myform.loginname.value.length==0)");
out.println("{alert('Please Enter Login Name.');");
out.println("return false;}");
out.println("if(document.myform.password.value.length==0)");
out.println("{alert('Please Enter Password.');");
out.println("return false;}");
/**********************JDBC CONNECTION************************/
try
{
i=1;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con =DriverManager.getConnection("jdbc dbc:vaibhav","vaibhav","vaibhav");

String query="SELECT * FROM Administrator WHERE login=? AND password=?";
pstmt = con.prepareStatement(query);
pstmt.setString(1,req.getParameter("loginname"));i++;
pstmt.setString(2,req.getParameter("password"));i++;
rst=pstmt.executeQuery();

//does not reach here---- while(rst.next())
{

{
//defined at class level loginnamearr[i-1]=rst.getString("login");
passwordarr[i-1]=rst.getString("password");
out.println(" if(document.myform.loginname.value!="+loginnamearr[i-1]+") ");
out.println(" { alert('Login Name Incorrect.'); return false;} ");
out.println(" if(document.myform.password.value!="+passwordarr[i-1]+") ");
out.println(" { alert('Password Incorrect.'); return false;} ");
out.println(" else{ document.myform.submit();} ");
out.println(" return true;}");
out.println("-->");
out.println("</script>");
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic