View Single Post
Old 04-09-2005, 11:30 PM   #6 (permalink)
j.gohel
Code Monkey
 
Join Date: Apr 2005
Posts: 68
j.gohel is on a distinguished road
re:::

Hello

I am able to connect to the ldap server by calling the Add.java class into any .java class and it connects successfully but the entry is not added
The code for the Add.java is being checked standalone also only it does not run with the servlet.

But when i call the same code within the servlet it does not show the result
The log file within the container od the servlet shows

LDAPException not found in doPost() method

Here is my servlet code

Code:
package com.chat.java; import netscape.ldap.*; import netscape.ldap.util.*; import netscape.ldap.controls.*; import java.io.*; import java.sql.*; import javax.servlet.ServletException; import javax.servlet.http.*; import javax.swing.*; import netscape.ldap.LDAPConnection; import com.chat.ChatRoomList; import com.chat.ChatRoom; import com.chat.Add; public class LoginServlet extends HttpServlet { LDAPConnection ld ; boolean flag = false; String s1,s2; int i = 1800; public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { doPost(req,res); } public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) throws ServletException, IOException { String s = "jdbc:odbc:chat"; contextPath = httpservletrequest.getContextPath(); s1 = httpservletrequest.getParameter("nickname"); s2 = httpservletrequest.getParameter("pwd"); s1 = s1.trim().toLowerCase(); if(s2.length() > 0) s2 = s2.trim().toLowerCase(); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connection = DriverManager.getConnection(s); Statement statement = connection.createStatement(); for(ResultSet resultset = statement.executeQuery("select * from Login"); resultset.next();) { String s3 = resultset.getString(1); String s4 = resultset.getString(2); if(s1.equals(s3) && s2.equals(s4)) { flag = true; } } }//try ends here catch(SQLException sqlexception) { System.out.println("Error...." + sqlexception); } catch(ClassNotFoundException classnotfoundexception) { System.out.println("Error...." + classnotfoundexception); } if(flag=true) { try { ChatRoomList chatroomlist = (ChatRoomList)getServletContext().getAttribute("chatroomlist"); boolean flag1 = chatroomlist.chatterExists(s1); // THIS IS THE PLACE WHICH DOES NOT HAPPEN // THE OBJECT IS NOT CREATED // EXECUTION AFTER IT STOPS Add add = new Add(); System.out.println("After add"); if(flag1) { JOptionPane.showMessageDialog(null,"U have already Login......","Information",JOptionPane.INFORMATION_MESSAGE); } else { HttpSession httpsession = httpservletrequest.getSession(true); int i = 1800; String s2 = getServletContext().getInitParameter("sessionTimeout"); if(s2 != null) try { i = Integer.parseInt(s2); i *= 60; } catch(NumberFormatException numberformatexception) { } httpsession.setMaxInactiveInterval(i); httpsession.setAttribute("nickname", s1); } }//try ends catch(Exception exception) { System.out.println("Exception thrown in LoginServlet: " + exception.getMessage()); exception.printStackTrace(); } }//if ends here else { JOptionPane.showMessageDialog(null,"Server is saying that Invalid User","Information",JOptionPane.INFORMATION_MESSAGE); } }//do post ends here private final void _mththis() { contextPath = ""; } public LoginServlet() { _mththis(); } private String contextPath; ObjectOutputStream out=null; }

Please help

Regards
Jignesh
__________________
j.gohel is offline   Reply With Quote