Sbucareer's Posts
Nairaland Forum › Sbucareer's Profile › Sbucareer's Posts
1 2 3 4 5 6 7 8 ... 20 21 22 23 24 25 26 27 28 (of 38 pages)
If you want to get a datatype you will use a PHP reserved function called gettype() We will talk about functions later in the tutorial <HTML> <HEAD> <TITLE>Printing data types</TITLE> </HEAD> <BODY> <?php $age = 23; echo gettype($age); // prints out: interger ?> </BODY> </HTML> To learn more about internal function visit here |
<HTML> <HEAD> <TITLE>Customer Details</TITLE> </HEAD> <BODY> <?php $name="nairaland"; $age= 2; $address="23 Lagos street"; $dob=20031983; $country="Nigeria"; $phoneNumber="0237454090"; $sex="M"; echo $name "\"\n"; echo $age "\"\n"; echo $address "\"\n"; echo $dob "\"\n"; echo $country "\"\n"; echo $phoneNumber "\"\n"; echo $sex "\"\n"; ?> </BODY> </HTML> |
TYPES PHP supports eight primitive data type 1. boolean 2. float 3. integer 4. String Object or compound types 5. Object 6. Array The two special types are the 7. resource 8. null Data types are very important in programming language. Infact data types are the programming itself. If you can understand data types of any language you have already half way to learning the language. Why is data type so important? Well, everything we do with program is, manipulation of memory address and finally storing it to a permanent storage like database. So why data type. Like in database we need to know how to represent a particular information like customer. In database, if we want to represent customer in a database we need to know the attributes or variables of the customer i.e name, age, address, date of birth, country, phone number, sex etc. All these attributes are not the same. Some are real numbers, some are characters, some are mixed numbers (float), some are integers, some are just yes or no It would be wrong to categorise all data type as one data type. It would probably introduce buy in our program and curse memory leaks. Writing program language is no different from creating a database like customer table, because you have to think about its attributes and initial states. In PHP we use data type to represent complex data structure, like customer, order, employee details and store records. to declare a data type we use the $ sign in front to the variable name. Example, let represent customer details in PHP program $name="nairaland"; $age= 2; $address="23 Lagos street"; $dob=20031983; $country="Nigeria"; $phoneNumber="0237454090"; $sex="M"; This is how we declare and initialize variables in PHP. We will go into object and resource type later in the tutorial. So to call these variable within an application we simply write a HTML file and save it as .php extension and put it in you apache directory folder called htdocs |
Rhodalyn, what is the problem? |
Another way is to open the httpd.txt in the conf directory folder and locate the LoadModules i.e. LoadModule access_module modules/mod_access.so LoadModule actions_module modules/mod_actions.so LoadModule alias_module modules/mod_alias.so LoadModule asis_module modules/mod_asis.so LoadModule auth_module modules/mod_auth.so #LoadModule auth_anon_module modules/mod_auth_anon.so #LoadModule auth_dbm_module modules/mod_auth_dbm.so #LoadModule auth_digest_module modules/mod_auth_digest.so LoadModule autoindex_module modules/mod_autoindex.so #LoadModule cern_meta_module modules/mod_cern_meta.so LoadModule cgi_module modules/mod_cgi.so #LoadModule dav_module modules/mod_dav.so #LoadModule dav_fs_module modules/mod_dav_fs.so LoadModule dir_module modules/mod_dir.so LoadModule env_module modules/mod_env.so #LoadModule expires_module modules/mod_expires.so #LoadModule file_cache_module modules/mod_file_cache.so #LoadModule headers_module modules/mod_headers.so LoadModule imap_module modules/mod_imap.so LoadModule include_module modules/mod_include.so #LoadModule info_module modules/mod_info.so LoadModule isapi_module modules/mod_isapi.so LoadModule log_config_module modules/mod_log_config.so LoadModule mime_module modules/mod_mime.so #LoadModule mime_magic_module modules/mod_mime_magic.so #LoadModule proxy_module modules/mod_proxy.so #LoadModule proxy_connect_module modules/mod_proxy_connect.so #LoadModule proxy_http_module modules/mod_proxy_http.so #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so LoadModule negotiation_module modules/mod_negotiation.so #LoadModule rewrite_module modules/mod_rewrite.so LoadModule setenvif_module modules/mod_setenvif.so #LoadModule speling_module modules/mod_speling.so LoadModule status_module modules/mod_status.so #LoadModule unique_id_module modules/mod_unique_id.so LoadModule userdir_module modules/mod_userdir.so #LoadModule usertrack_module modules/mod_usertrack.so #LoadModule vhost_alias_module modules/mod_vhost_alias.so #LoadModule ssl_module modules/mod_ssl.so LoadModule php4_module "c:/php/php4apache2.dll" The red line is where I told apache to find php.ini, like Ynot said earlier. Also find in the conf folder # configure the path to php.ini PHPIniDir "C:/temp/php" This will tell the server to look for php.ini in that folder. You can create any folder name, I chose the c:/temp/php, it is optional |
Create a PHP file and call it anything and put it in the htdocs folder and access it from your browser i.e. http://localhost/filename.php <HTML> <HEAD> <TITLE>Testing if PHP is installed</TITLE> </HEAD> <BODY> <?php phpinfo(); ?> </BODY> </HTML> This would show you details of your PHP setting and whether PHP is installed or NOT |
To test your ASDL connection visit ADL Test |
Because PHP is an extension of programming language and mimic C/C++ in the manner of API's calls and design paradigm. You do not need to know programming language to learn PHP. If you have programmed before, learning PHP would be a lot easier for you. But programming language involves manipulation of memories and registers in the CPU cache memory. Because technologies have emerge, we do not need to learn all the memory address of a computer memory. All we need is to use a variable to reference a location in the memory our compiler will handle the actual physical location and apply operation to do our tasks. What is a variable? Well a variable is a peace of container you put things. Like women, their hand-bag is there variable because the can put lots of things in there whether they remember it or not is not really important because they can open their hang-bag and look for their lipstick and retrieve it. In computer, we use variables to store state i.e lipstick. Like a hang-bag, we can store many things not anything, because we canot put a car in a hand-bag, we can then store state into a variableand when we need it back we simply call the vvariablename back. Example In PHP we declare variablesby using $ in front of a name. Say I want to store someones age, I would say that the variable name would be called age just to let me know what type of variable I am dealing with, we write it like this $age and I would need to initial it. To do that I would need an assignment operator like = i.e. $age = 21, because is untyped language you do not need to tell the compiler the type of age i.e. iinteger char, int, byte etc. The compiler works out at compile-time what the type is, which if you ask me is very dangerous. But I am not PHP architectsthat made this decision during the birth of PHP. |
Ynot, thank you very much for pointing out that issue. also Ynot if you could help me co-author this tutorial please, it seems you know your stuff. |
When you have finished installing PHP and apache server and run the http://localhost/phpinfo.php and it return true. Then try and install MSQL, it does not need any special configuration with Apache or php. I will show you how to connect to a database, even if the database is in a remote location (different location where you apache server is). Write a simple HelloWorld and save it into the folder htdocs and access the HelowWorld by typing http://localhost/HelloWorld.php. Here is the HellowWorld Script <HTML> <HEAD> <TITLE>My Hello World </TITLE> </HEAD> <BODY> <?php echo '<p>Hello World</p>'; ?> </BODY> </HTML> The the file into htdocs folder as hellowWorld.php as access it from a broswer as http://localhost/hellowWorld.php. If you have any problem so far let us know |
You often hear PHP and MYSQL. Well, any web application development that needs to remember person or your business transaction with that web site would need a way to save your conversation with them. We use database as a storage mechanism. In software engineering we use state to depict the conversational elements of a particular person with a web site. State has elements and behavior. A state is the elements that makes up a particular event, which could occur over and over again. MYSQL, is a powerful transactional database management system. Engineers have employed the traditional relational schema and other database features. MYSQL is NOT free, but has a license for open source community for none profit usage and personal use. You can download and use MSQL for free as long as it is NOT for profit purposes. If you want to use it for profit you would need to get a license from MSQL website or by phoning them. MYSQL could be downloaded from here and instruction on installation in windows here |
I do not want to start re-inventing the wheel as many wheels have already been invented. To configure installed Apache with PHP follow this link After the above link tutorial open your browser and type http://localhost/phpinfo.php, you will see your server php configuration list. If that is true your PHP is configured and you can start writing PHP script. I forgot to mention this in the earlier tutorial. To access any web application, since PHP is a web application you would need a browser and to access the page you need to know the domain name. In this instance our domain name is localhost. So you'd done this http://localhost Remember if you have followed my instruction above and change the port to 80 you would NOT need to to this http://localhost:8080. Remember in folder htdocs every folder there is a new application context. i.e if I have a folder under htdocs like 1. solicitor 2.trader To access them I'd done this htt://localhost/solicitor and http://localhost/trader respectively. So you can have many host in one server that is how host company used in hosting many people on their server. They don't run a server per person they use virtual hosting. The way it works it to create folder for each person and allow them access it using their folder name(s) |
To understand apache server is to understand the folders directory structure. After installing apache you would see a structure like this assuming you installation was in c:\program fils\apache group\apache2 There are about 12 folders in apache 2.0 namely: 1. bin 2. conf 3. htdocs 4. include 5. logs 6. modules 7. cgin-bin 8. error 9. icons 10 lib 11 manual 12 proxy After installation of any software, a good place to start is the README.txt file. It is usually install in the root directory of the software installed. It is important to read it. In the above directory the once to particularly be aware of are the 1. bin 2. conf 3. htdocs 4. modules The most important of them all is the htdocs, this is where you put your HTML files that you have patiently developed for a company that paid you money to design a website for them. Now to configure that server from hackers and other software virus you need to explore the conf directory, which means configuration directory. The most important file there is the httpd.txt. Use an editor or notepad to edit it. If there is an error in this file the server will NOT start. It is wise to make a back up httpd.txt before modifying it. To learn for about modifying it visit apache documentation Modules are where you add new modules for the server and add it in the httpd.txt at line addModule |
For the simplicity of the tutorial I would be providing basic tools configurations in Windows environment. If you use Unix of any flavor I'd say you are a little bit technical and would not find it challenging to get apache in you box up and running with PHP. For window users, download [url=http://httpd.apache.org/download.cgi?Preferred=http%3A%2F%2Fapache.rmplc.co.uk]apache 2.0[/url] and save it in your c:\temp. Navigate to PHP and download PHP 5.1.2 and save it in your c:\temp directory. If you downloaded a zipped archive you would need an unzip program to extract the files out of the cabinate. If they came in executable form, you have to follow the installation wizard, make sure that your server port is changed to port 80 from 8080, which is there by default. When you finished extracting your PHP files or executing the installation go to the directory and copy php.ini into C:\windows |
[size=24pt]PHP basics[/size] [size=14pt]What is PHP?[/size] PHP means P[/b]HP [b]H[/b]ypertext [b]P[/b]reprocessor. PHP is script language and it is only used in server side processing. The basic knowledge needed before learning PHP would be 1. HTML/XHTML 2. Some scripting knowledge i.e (DOS batch script) 3. Database design and querying (Only if you want dynamic HTML behavior) The tools you will need are mostly free and Open Source Software (OSS). PHP is like Microsoft ASP, ASP.NET, VB.NET, C#.NET, J#.NET, JSP, Perl, CGI, Python script and other server side scripting. What is server side scripting? Well, it is a special API's written in many different languages that make absolutely used of the HTTP, HTTPS, FTP, GOPHER and other web communication protocol that uses the [b]request and response mechanism to communication to a container in a remote location. A container, is used by web protocol developers to denote a Framework that allows a web application server to have a standard and conform to the internalization of basic technology so that web servers understands each other regardless the provider. In other word a web container is a peace of software you can install in your choice of OS (Operating System) that default uses the HTTP port 80 to listen to requests on the WWW and can construct a response back to the client depending if all the security issues involves with that request is fullfiled. We have lots of web container and most of them runs only one script language others runs many. Like Mircosoft .NET runs lots of script language i.e. 1. ASP 2. VB 3. C# 4. J# Java is not a script language but has provided API's for people interested in using java in web development. Java uses containers like tomcat, a Jakarta project and Sun that engineered Java provides Container with more complex features to managing script language called Application Server. It runs EJB (Entity Java Bean), which is a specification for running Web Application developed for with Java. Apache group has been an old group of computer engineer architects that researches and produce recommendations and standards to Open source Community and other government affiliate that regulates IEEE. Apache has pioneered many project including the development of Java API's for web containers to ant, a simple build tool for easy software deployment. Ant was a former UNIX shell called make, used in building and compiling application in the Unix environment. Because PHP is just a script language it needs a container to run with. The only container that I know of that runs PHP scripts API's is apache. Apache is a HTTP container (Web Server). The power of Apache is that it runs many script language, from Java to python and CGI. But unfortunately, it does not run all these script in one simple container. You have to download the particular container you want to develop in with i.e. say you want to write Perl script, you'd download apache and say for java you had download tomcat and so on. For this tutorial on PHP we need apache container for PHP. We also need to download the PHP API's binary since it is another open source community that writes and maintains it. |
Gbenga, send me your address via [email=valentine.obih@gmail.com?subject=DVD Software Compilation for Nairaland]email[/email] I will send it on Friday 14-04-06 |
Alexis, I'm still waiting for you to start the comprehensive PHP tutorial introduction so we can co-author the lessons. |
Gbenga, you know I live in London and I know how the system works. Believe me Gbenga, you do NOT work anymore harder than I do. Still I have time to response to all my online and virtual news group and forum messages. The thing is that, I know we are all busy especially when you live in developed world, time is NEVER your friend. I understand your undertakings, but!! you still can find time and do some work. It is for your interest assuming you seriously want to learn Java. I work 18hrs a day, Monday to Friday, weekend I do teaching for 12hrs and yes I go to church on Sunday. You know Nigerian Churches in the UK, if they have not cast that demon out of people they will not finish the service. I do this every week, month, year for the past 6 years now. Tell me if you are more busier than me? |
Gbenga, SE is a specialized course. Most people that study SE do it at MSc level. There is compulsory prerequisite for doing this Course. Listen to the name Software Engineering. So you need to learn to write it before you can engineer it. Software Engineering is not all about writing codes. It is all about learning principles rather to skills. A graduate with SE degree can come out and go into a CTO position without problem assuming he learned all the principles involved, i.e. taking a vague and ambitious specifications and turn it into a system design that can be built and launched within a few months, with the most important-to-users and easy-to-develop features built first and the difficult bells and whistles deferred to a second version. You see the principle, you cannot learn this by just studying codes. These days most university in the UK have started teachin SE at undergraduate level, I'd be suprise if no universities these days teaches SE It is better to do a BSc Computer Science and come out with a good result at least 2:1 and go on to do MSc. Software Engineering, you'd come out and look at programmers like babies. |
What has happened to all my students, especially Skima, are you upset with me regarding the DVD? I have promised to DHL it to you on 14-04-06 come rain or sun. Gbenga, where are you? Nairaland where is everybody? Do you want me to stop the thread? It would be a shame. I need the assignment latest by weekend. Just show what you have done. Even if you have only done the diagrams, we will work together to build your LagosTemperature class. |
This is simple logic problem here is my solution The three guys paid $30.00 but it was actually $25.00. So they got there 5 X $1 coins back ($5.00) and get $1.00 each that is $28.00 ($25.00 + $3.00=$28.00) plus the $2.00 tip which is $30.00 |
People I am terribly sorry particularly to Skima who has asked me this favor for a long time now. I have burned the softwares into a DVD as it size is about 3.8GB. I will send it to Skima next week Friday as there will be a bank holidays for the Esther celebration. The link in-case you have a fast download speed.Download it here, my connection upload is 1.3MB, reasonably fast. I use this ISP now. Username: visitor password: letmein |
During my years as a student at university I did a course called Distributed Computer System tutored by Dr Frank Devai at London South Bank University. We did parallel Algorithm used to coordinate heterogeneous computers to either share Memory or CPU and work out the scalability issues. I used this link alot on most of my research and assignment. I am quite suprise the link is still there in my bookmark. I don't know if it would be of any help to you? Good luck. |
My advise to people learning C# is that Microsoft borrowed C# from Java. C# is the same things as Java. No difference. Almost same API, syntax and exception handling. So, you are better off learning Java. Even j# was MS challenge to java in the early days, but J# did not really take-off. The only MS language that commands articles and job in the market place is .NET and ASP, which I think uses the VB (Visual Basic). Although MS have stop support on VB 6.0. MS is encouraging everyone to move to .NET 2005 You use .NET VB, C#, j# to develop standalone application or forms and use ASP.NET VB, C#, j# etc to develop web applications or web forms. |
Seun why? Most good programmers I know today do not speak English let alone write English. Programming is an art, it involves self expression. Many people in our society today particularly in Nigeria today are genius, because they could not speak or write English Language people look down on them, what a sad society! My brother follow Skima link or try to learn any language you feel comforbale with. IDE (Integrated Development Environment) will depend on the language you learn. Most of the tutorials on the net will give you a short requirements before going into the tutorials. Integrated Development Environment is a software suite where you type your codes, compile and run your application. In java I use Java Studio Enterprise 8 People in Microsoft uses Microsoft visual studio It is not free. MS is a proprietary company and have a trademark to all there products. Look luck. |
From the above example you can deduce your own solution to papa assignment. The assignment is similar to this one if not the same, just convert the English word to Romans Numerals For people using Java store your Roman Numerals in a Collection framework like HashMap to store your Roman Numerals i.e. String [] romansNumerals= {"I", "II", "II", "IV", "V", "VI", "VII", "VIII", "IX", "X", "L", "C", "M", " "},Use for loop to add it into a collection framework like HashMap API. HashMasp units = new HashMap(); for( int index = 0; index < romanNumerals.lenght(); index++ ){ units.put(romanNumerals[index], romanNumerals[index]); }//End for loop , In your functions i.e convert1, convert2, convert3, etc, that is where you will use your units object above. good luck, people. |
The function convert2 returns the English name of any number n in the range 0 < n < 100. For example: convert2 31 returns thirty-one convert2 :: Int -> String digit2 :: Int -> (Int, Int) convert2 n = combine2 (digit2 n) digit2 n = (n div 10, n mod 10) In the above example we realise that n from 0 < n < 10 and uses mod a mathematical operator that checks if dividing n/2 will produce a remender. here, The definition of combine2 is: combine2 :: (Int, Int) -> String combine2 (t,u) | t == 0 = units u | u == 0 = tens t | t == 1 = teens u | otherwise = tens t ++ "-" ++ units u The function convert3 returns the English name of any number n in the range 0 < n < 1000. For example: ? convert3 102 one hundred and two convert3 :: Int -> String digit3 :: Int -> (Int, Int) convert3 n = combine3 (digit3 n) digit3 n = (n div 100, n mod 100) The definition of combine3 is: combine3 :: (Int, Int) -> String combine3 (h,t) | h == 0 = convert2 t | t == 0 = units h ++ " hundred" | otherwise = units h ++ " hundred and" ++ convert2 t The function convert6 returns the English name of any number n in the range 0 < n < 1,000,000. For example: convert6 308000 three hundred and eight thousand convert6 :: Int -> String digit6 :: Int -> (Int, Int) Convert6 n = combine6 (digit6 n) digit6 n = (n div 1000, n mod combine6 :: (Int, Int) -> String combine6 (m, h) | m == 0 = convert3 h | h == 0 = convert3 m ++ " thousand" | otherwise = (convert3 m) ++ " thousand" ++ link h ++ convert3 h link h | h < 100 = " and " | otherwise = " " 1000) |
Now that we have seen how to divide complex task into smaller units we will go on to solve the problem. The function units returns the English name for the one digit numbers. units :: Int --> String convert1 = units Example units 1 = "one" units 2 = "two" units 3 = "three" units 4 = "four" units 5 = "five" units 6 = "six" units 7 = "seven" units 8 = "eight" units 9 = "nine" The function tens returns the English name for those two digit numbers which are multiples of ten. tens :: Int --> String tens 1 = "ten" tens 2 = "twenty" tens 3 = "thirty" tens 4 = "forty" tens 5 = "fifty" tens 6 = "sixty" tens 7 = "seventy" tens 8 = "eighty" tens 9 = "ninety" Similarly, the function teens returns the English name for the numbers in range eleven to nineteen. teens :: Int --> String teens 1 = "eleven" teens 2 = "twelve" teens 3 = "thirteen" teens 4 = "fourteen" teens 5 = "fifteen" teens 6 = "sixteen" teens 7 = "seventeen" teens 8 = "eighteen" teens 9 = "nineteen" |
Oky, let take a case study of converting numbers to words Sometimes we need to write numbers in words. For example, to fill out a cheque or a cash transfer. We need to design a function convert6 that takes an integer n drawn from a given range, say greater than zero and less than one million, and returns a list of characters corresponding to the usual English formulation of the whole number n. For Example: ? convert6 459213 four hundred and fifty-nine thousand two hundred and thirteen. The first question you ask yourself is how do I start this complex mathematical solution? Well, wee need to understand it mathematical paradigm first before going into programming it. To solve this start by solving the smallest task by employing a technique that I was taught at university by Mr Clive Hayton a senior lecturer at School of Information Systems and Mathematic, called Divide and conquer Divide the tasks into smaller solvable units and add them up to form a big complex solution called conquer. Here, Start by solving the problem for all input < 10 Extend your design to solve the problem for all input < 100 Extend your design to solve the problem for all input < 1000 Extend your design to solve the problem for all input < 10000 Example convert6 3 three convert6 11 eleven convert6 30 thirty convert6 97 ninety-seven convert6 125 one hundred and twenty-five convert6 1000 one thousand convert6 286000 two hundred and eighty-six thousand convert6 260006 two hundred and sixty thousand and six convert6 is a function, i.e. f:x --> x + 2 which means the function f takes an input x and produces an output x + 2. In the above convert6 take an input say n where n is integer and produce English word equivalent. Example if n is applied to to function convert6 as an input the resultant would be Three, where n = 3. |
Look at a loginUser example using Stateless session bean in J2EE environment. I do not need to explain all the classes involved as you will have already known that since you are SCJP 1.4 SCJA (Beta) SCWCD 1.4 SCBCD 1.3 This is DAO objects Data Access Object session bean helpper classes //* * StoreAccesDAO.java * * Created on 10 March 2006, 02:56 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package ejb.dao; /** * * @author Administrator */ public interface StoreAccesDAO { public String loginUser(String username, String passwd); } /* * CustomerDAOImp.java * * Created on 10 March 2006, 13:34 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package ejb.dao; /** * * @author Administrator */ public class CustomerDAOImp { /** Creates a new instance of CustomerDAOImp */ public CustomerDAOImp() { } } /* * StoreAccessDAOImp.java * * Created on 10 March 2006, 02:59 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package ejb.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import javax.naming.InitialContext; import javax.sql.DataSource; /** * * @author Administrator */ public class StoreAccessDAOImp implements StoreAccesDAO{ DataSource jdbcFactory; /** Creates a new instance of StoreAccessDAOImp */ public StoreAccessDAOImp() { InitialContext cxt =null; if(jdbcFactory == null ){ try{ jdbcFactory = (DataSource) cxt.lookup("java:comp/env/jdbc/mysql" ;}catch(Exception e){ e.getMessage(); }//End catch }//End if }//End StoreAccesDAOImp public String loginUser(String username, String passwd){ Connection con = null; PreparedStatement stmt = null; ResultSet rs = null; String userId = null; boolean result; String query ="select from storeaccess where username=? and password=? "; try{ con = jdbcFactory.getConnection(); stmt = con.prepareStatement(query); stmt.setString (1, username); stmt.setString(2, passwd); rs = stmt.executeQuery (); result = rs.next(); if(result){ userId = rs.getString("userid" ; }//End if }catch(Exception e){ e.getMessage(); }//End catch finally{ try{ con.close(); stmt.close(); rs.close(); }catch(Exception e){ e.getMessage(); } } return userId; }//End loginUser } Now these objects are called into the statelessBean i.e. package ejbSession; import java.rmi.RemoteException; import javax.ejb.*; /** * This is the bean class for the StoreAccessBean enterprise bean. * Created 09-Mar-2006 22:59:20 * @author Administrator */ public class StoreAccessBean implements SessionBean, StoreAccessRemoteBusiness { private SessionContext context; private ejb.dao.StoreAccesDAO dao = null; public void setSessionContext(SessionContext aContext) { context = aContext; } /** * @see javax.ejb.SessionBean#ejbActivate() */ public void ejbActivate() { } /** * @see javax.ejb.SessionBean#ejbPassivate() */ public void ejbPassivate() { } /** * @see javax.ejb.SessionBean#ejbRemove() */ public void ejbRemove() { } public void ejbCreate() { } public String loginUser(String username, String passwd)throws RemoteException { dao.loginUser(username, passwd); return getDAO().loginUser(username, passwd); } protected ejb.dao.StoreAccesDAO getDAO(){ if (dao != null){ return dao; }else{ dao =(ejb.dao.StoreAccesDAO) new ejb.dao.StoreAccessDAOImp(); return dao; }//End if }//End getDAO } package ejbSession; import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.ejb.EJBHome; /** * This is the home interface for StoreAccess enterprise bean. */ public interface StoreAccessRemoteHome extends EJBHome { StoreAccessRemote create() throws CreateException, RemoteException; } package ejbSession; /** * This is the business interface for StoreAccess enterprise bean. */ public interface StoreAccessRemoteBusiness { String loginUser(String username, String passwd) throws java.rmi.RemoteException; } package ejbSession; import javax.ejb.EJBObject; /** * This is the remote interface for StoreAccess enterprise bean. */ public interface StoreAccessRemote extends EJBObject, StoreAccessRemoteBusiness { } Let me know if you do not understand it |
I forgot this, never use SQL statement in the front-end. Use Beans helpper classes to wrap up all the SQL statements. Another way is to use Stateful Session beans. Very bad idea to use SQL in front-end. How about a web designer who do not know SQL and is employ to maintain you web apps? Above all, it breaks the golden rule of modularity. Remember J2EE specifications for developing distributed application 1. All web application i.e. jsp, html, jsfl, *.gif, applets, web.configuration-files depolyed into WAR ([b]W[/b]eb [b]Ar[/b]chive) 2. All beans application i.e. *.java sun.configurations and xml-configurations deployed into JAR ([b]J[/b]ava [b]A[/b]rchive) 3. All the J2EE components i.e. WAR and JAR deployed into EAR ([b]E[/b]nterprise [b]Ar[/b]chive) When I am less busy I will show you a simple application using this paradigm. |
1 2 3 4 5 6 7 8 ... 20 21 22 23 24 25 26 27 28 (of 38 pages)
"},
;