CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 2150|Reply: 10

error dlm Java servlet&JavaBean..tlg solve kan..plsss

[Copy link]
nur_imann This user has been deleted
Post time 25-7-2007 11:07 AM | Show all posts |Read mode
saper-saper bleh tolong tgkkan error nih..aper maksud dia ye?


dpt error mcm nih..

LoginServlet5.java:28:cannot resolve symbol
symbol: class LoginBean
location : class project1.LoginServlet5
               
                LoginBean lb = new LoginBean();
                ^

LoginServlet5.java:28:cannot resolve symbol
symbol: class LoginBean
location : class project1.LoginServlet5
               
                LoginBean lb = new LoginBean();
                                   ^

2 errors
Reply

Use magic Report


ADVERTISEMENT


Post time 25-7-2007 01:05 PM | Show all posts
macam salah board je nih...

kalo ye pon bagi la the whole coding nye...

camne nak detect kalo ko bagi errors je...adeh
Reply

Use magic Report

Post time 25-7-2007 01:20 PM | Show all posts
classpath betul ?
Reply

Use magic Report

Post time 25-7-2007 02:19 PM | Show all posts
Thread moved to Programming & Networking Board.
Reply

Use magic Report

Post time 25-7-2007 02:40 PM | Show all posts
class LoginBean dah create?
class LoginBean dah include dalam classpath?
class LoginBean dah import dalam your source code?

[ Last edited by  shahnazz at 25-7-2007 02:42 PM ]
Reply

Use magic Report

nur_imann This user has been deleted
 Author| Post time 25-7-2007 04:59 PM | Show all posts
ops..eh salah board ker..adehh..hehhehe..sory arr org_letrik.

ni utk org letrik..
directory utk file nih...C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\project\WEB-INF\classes\project1..

coding for LoginServlet5.java..
package project1;

import java.io.*;
import java.net.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
* This servlet simply prints out HTTP method name and query string in it's service method.
*
*/
public class LoginServlet5 extends HttpServlet
{
        //If somebody types up the URL for this servlet
        //in the address field of the browser.
        public void doGet(HttpServletRequest req, HttpServletResponse res) throws javax.servlet.ServletException, java.io.IOException
        {
                doPost(req, res);
        }
        public void doPost(HttpServletRequest req, HttpServletResponse res) throws javax.servlet.ServletException, java.io.IOException
        {               
                String userid = req.getParameter("userid");
                String password =req.getParameter("password");               

                if(userid != null && password != null  )
                {
                        LoginBean lb = new LoginBean();
                        boolean verified = lb.checkPassword(userid,password);
                        if (verified)
                        {       
                //set userid in request to pass it on to AccountServlet
                                req.getRequestDispatcher("/jspFiles/homepage.jsp").forward(req, res);
                        }
                        else
                        {
                        //userid,password verified. Forward request to AccountServlet.
                        //observe the use of absolute path.
                        req.getRequestDispatcher("/jspFiles/login2.html").forward(req, res);
                        return;
                        }
                }
                else
                {
                        //Unable to login. Send login.html to the user.
                        //observe the use of relative path.
                        req.getRequestDispatcher("/jspFiles/login2.html").forward(req, res);
                        return;                       
                }
          }

}
------------------------------------------------------------------------------------------------------------
ni plk untk codin LoginBean.java
directory utk file nih..
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\project\WEB-INF\classes\beans

package beans;

import java.sql.*;
import java.io.*;

public class LoginBean
{

String dbURL;
String dbDriver="sun.jdbc.odbc.JdbcOdbcDriver";
private Connection conn;
Statement stmt;
ResultSet rs;

public LoginBean() {}
  
public boolean checkPassword(String userid,String password)
        {
                  try{
                           String sql = "SELECT "+userid+" , "+password+" FROM Users";
                           connect();
                           stmt = conn.createStatement();
                           rs = stmt.executeQuery(sql);
                           if((rs !=null))
                                return true;
                           else
                                return false;
                        }
       
           catch(Exception e)
        {e.getMessage();}
          return false;
}
public boolean connect() throws ClassNotFoundException,SQLException
        {
        Class.forName(getDbDriver());
        conn=DriverManager.getConnection("jdbc.odbc.EmpDetails","","");
        return true;
        }

public ResultSet executeSQL(String sql) throws SQLException
        {
        stmt=conn.createStatement();
        rs=stmt.executeQuery(sql);
        if((rs==null))
                return null;
        else
                return rs;
        }

public String getDbDriver()
        {
        return dbDriver;
        }

public void setDbDriver(String newVal)
        {
        dbDriver=newVal;
        }

public String getDbURL()
        {
        return dbURL;
        }

public void setDbURL(String newVal)
        {
        dbURL=newVal;
        }

public void close()throws SQLException
        {
        conn.close();
        }
}

thank you for advance...
Reply

Use magic Report

Follow Us
Post time 25-7-2007 05:10 PM | Show all posts
setkan CLASSPATH ...
cth set CLASSPATH=%CLASSPATH%;C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\project\WEB-INF\classes

lepas tu mula compile
mulakan dari directory
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\project\WEB-INF\classes\beans
javac *.java

lepas tu compile file dalam directory
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\project\WEB-INF\classes\project1
javac *.java
Reply

Use magic Report

nur_imann This user has been deleted
 Author| Post time 25-7-2007 05:37 PM | Show all posts
utk ultra78..

classpath dah set dah..point to:--->>
C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\project\WEB-INF\classes\

btul ker?
Reply

Use magic Report


ADVERTISEMENT


nur_imann This user has been deleted
 Author| Post time 25-7-2007 05:44 PM | Show all posts
moderetor,....Terima kasih ye moved kan problem tu dlm board nih..

for your questions....
class LoginBean dah create?
class LoginBean dah include dalam classpath?
class LoginBean dah import dalam your source code?

dah buat dah semua tu...

anyway,thanks ya'
Reply

Use magic Report

Post time 7-8-2007 08:17 PM | Show all posts
Dekat file LoginServlet5.java tuh import sekali beans....pasal yg first tuh dlm package project1 yg lagi satu lak dlm package beans...That why error dia tulis "cannot resolve symbol"..dia tak jumpa class LoginBean dlm package beans tuh...hope can help u
Reply

Use magic Report

Post time 8-8-2007 07:40 PM | Show all posts
packagekan folder beans jadi beans.jar. then masukkan dlm ...WEB-INF/lib/ jadi mcm ni -> C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\project\WEB-INF\lib\beans.jar. Pas tu kat kawasan import ko tu, tambah line ni -> import beans.*;

pas tu compile. jgn lupa masa compile tu setkan classpath C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\project\WEB-INF\lib\beans.jar

tapikan senang klu ko pakai JAVA IDE editor mcm netbeans / ECLIPSE. senang nak compile. Buat coding pun senang..
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

3-1-2025 12:47 AM GMT+8 , Processed in 0.052235 second(s), 26 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list