Friday, November 13, 2009

WRITE YOUR FIRST JAVA CLASS




HOW TO WRITE YOUR FIRST JAVA CLASS.docx

HOW TO WRITE YOUR FIRST SERVLET




1.HOW TO WRITE YOUR FIRST SERVLET.doc

WHAT IS ADSL ??? AND WHY MY ADSL CONNECTION IS SLOW???



WHY MY ADSL CONNECTION IS SLOW.doc

Wednesday, November 11, 2009

Advantages of JSP:-


• JSP are translated and compiled into JAVA servlets but are easier to develop than JAVA servlets.

• JSP uses simplified scripting language based syntax for embedding HTML into JSP.

• JSP containers provide easy way for accessing standard objects and actions.

• JSP reaps all the benefits provided by JAVA servlets and web container environment, but they have an added advantage of being simpler and more natural program for web enabling enterprise developer

• JSP use HTTP as default request /response communication paradigm and thus make JSP ideal as Web Enabling Technology.

SERVLET OR JSP?



•Well, if servlets can do whatever JSP pages can, and vice versa, what is the difference between them? And if JSP pages are that easy to write, why bother learning about servlets?

•Servlets are server extensions and provide extra functionality to the main server. This could include implementation of specialized services, such as authentication, authorization, database validation, and transaction management. Servlets act as controller components that control the business logic. They are developed by Java programmers with strong object-oriented programming skills.

•On the other hand, JavaServer Pages are web pages. They are similar in structure to HTML pages at design time. Any web page designer who has some knowledge of JSP tags and the basics of Java can write JSP pages.

•Web applications typically consist of a combination of servlets and JSP pages. A user-authentication process that accepts login and password information is a good example. The code that generates the HTML FORM, success and error messages, and so forth should be in a JSP page, while the code that accesses the database, validates the password, and authenticates the user should be in a servlet.Keep these conventions in mind:
• JSP pages are meant for visual presentation.
• Business logic is deferred to servlets.

JSP element types




Directives
•Directives provide general information about the JSP page to the JSP engine.

•There are three types of directives: page, include, and taglib.

•A page directive informs the engine about the overall properties of a JSP page. For example, the following page directive informs the JSP engine that we will be using Java as the scripting language in our JSP page:<%@ page language="java" %>

•An include directive tells the JSP engine to include the contents of another file (HTML, JSP, etc.) in the current page. Here is an example of an include directive:

<%@ include file="copyright.html" %>

•A taglib directive is used for associating a prefix with a tag library. The following is an example of a taglib directive:
<%@ taglib prefix="test" uri="taglib.tld" %>


UNDERSTANDING JSP PAGE DIRECTIVE ATTRIBUTES


A page directive informs the JSP engine about the overall properties of a JSP page. This directive applies to the entire translation unit and not just to the page in which it is declared. Table describes the 12 possible attributes for the page directive.


UNDERSTANDING JSP PAGE DIRECTIVE ATTRIBUTES

A page directive informs the JSP engine about the overall properties of a JSP page. This directive applies to the entire translation unit and not just to the page in which it is declared.

The import attribute
The import attribute of a page directive is similar to the import statement in a Java class.


(01)
Index.jsp
<html>
<body>
The page count is:
<% out.println(Counter.getCount()); %>
</body>
</html>

Counter.java
package foo;
public class Counter {
private static int count;
public static synchronized int getCount() {
count++;
return count;
}
}


(02)
Index.jsp
<html>
<body>
The page count is:
<% out.println(foo.Counter.getCount()); %>
</body>
</html>

Counter.java
package foo;
public class Counter {
private static int count;
public static synchronized int getCount() {
count++;
return count;
}
}

Use the page directive to import packages

(03)
Index.jsp
<%@ page import=”foo.*” %>
<html>
<body>
The page count is:
<% out.println(Counter.getCount()); %>
</body>
</html>

Counter.java
package foo;
public class Counter {
private static int count;
public static synchronized int getCount() {
count++;
return count;
}
}

To import multiple packages:
<%@ page import=”foo.*, java.util.*” %>
Use a comma to separate the packages. The quotes go around the entire list of
packages!

(04)
Index.jsp
<%@ page import="foo.*,java.util.*" %>
<html>
<body>
The page count is:
<% out.println(Counter.getCount()); %>
<% Date today=new Date();%>
<% out.println(today);%>
</body>
</html>

Counter.java
package foo;
public class Counter {
private static int count;
public static synchronized int getCount() {
count++;
return count;
}
}

Note:
We can also use multiple tags for readability. For example, the above page directive
can also be written as:

(05)
Index.jsp
<%@ page import="foo.*" %>
<%@ page import="java.util.*" %>
<html>
<body>
The page count is:
<% out.println(Counter.getCount()); %>
<% Date today=new Date();%>
<% out.println(today);%>
</body>
</html>

Counter.java
package foo;
public class Counter {
private static int count;
public static synchronized int getCount() {
count++;
return count;
}
}
NOTE :
import is the only attribute of the page directive that can occur multiple times
in a translation unit. Duplicate values are ignored.

(06)
Index.jsp
<%@ page import="foo.*" %>
<%@ page import="java.util.*" %>
<%@ page import="foo.*" %>
<%@ page import="java.util.*" %>
<%@ page import="foo.*" %>
<%@ page import="java.util.*" %>
<html>
<body>
The page count is:
<% out.println(Counter.getCount()); %>
<% Date today=new Date();%>
<% out.println(today);%>
</body>
</html>

Counter.java
package foo;
public class Counter {
private static int count;
public static synchronized int getCount() {
count++;
return count;
}
}

  • The session attribute
    The session attribute indicates whether the JSP page takes part in an HTTP
    session. The default value is true, in which case the JSP engine declares
    the implicit variable session. If we do not want the page to participate in
    a session, then we have to explicitly add the following line:


<%@ page session="false" %>

(07)
Index.jsp
<%@ page import="java.util.*" %>
<%@ page session="true" %>
<html>
<body>
<% Date created = new Date(session.getCreationTime());%>
<% out.println(created);%><br>
</body>
</html>

(08)
Index.jsp
<%@ page import="java.util.*" %>
<%@ page session="false" %>
<html>
<body>
<% Date created = new Date(session.getCreationTime());%>
<% out.println(created);%><br>
</body>
</html>
The errorPage and isErrorPage attributes During the execution of a page, it is possible that the embedded Java code will throw exceptions.Just as in normal Java programs, we can handle the exceptions in JSP pages using try-catch blocks. However,the JSP specification defines a better approach, which separates the error-handling code from the main page and thus promotes reusability of the exception-handling mechanism.In this approach, a JSP page uses the errorPage attribute to delegate the exception to another JSP page that has the errorhandling code.

(09)
Index.jsp
<%@ page errorPage="errorPage.jsp" %>
<html><body>
About to be bad...
<% int x = 10/0; %>
</body></html>

Note: Tells the Container, “If something goes wrong here, forward the
request to errorPage.jsp”.

errorPage.jsp
<%@ page isErrorPage="true" %>
<html>
<body>
<% out.println(exception.getMessage()); %>
</body>
</html>

NOTE: Confirms for the Container, “Yes, this IS an officially-designated
error page.”

• It is not necessary that the errorPage value be a JSP page. It can
also be a static file, such as an HTML page:
<%@ page errorPage="errorHandler.html" %>

• The isErrorPage attribute conveys whether the current page can act
as an error handler for any other JSP page. The default value of the isErrorPage
attribute is false.

• A true value allows the exception object to be used within the JSP
page. A false value indicates that you cannot use the exception object in the
JSP page.

(10)
Index.jsp
<%@ page errorPage="errorPage.jsp" %>
<html>
<body>
About to be bad...
<% int x = 10/0; %>
</body>
</html>
errorPage.jsp
<%@ page isErrorPage="false" %>
<html>
<body>
<% out.println(exception.getMessage()); %>
</body>
</html>

(11)
• You can declare error pages in the DD for the entire web app, and you
can even configure different error pages for different exception types, or HTTP
error code types (404, 500, etc.). The Container uses <error-page> configuration in the DD as the default, but if a JSP has an explicit errorPage page directive,the Container uses the directive.

Configuring error pages in the DD
You can declare error pages in the DD based on either the <exception-type>
or the HTTP status <error-code> number. That way you can show the client
different error pages specific to the type of the problem that generated the
error.

Error Pages
• There are three different types of error pages…

• Catchall exception error page…
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/errorPage.jsp</location>
</error-page>

• Note: You can override this in individual JSPs by adding a page directive
with an "errorPage" attribute.

• Explicit exceptions…
<error-page>
<exception-type>java.lang.ArithmeticException</exception-type>
<location>/arithmeticErrorPage.jsp</location>
</error-page>

• Note: The Container will choose the most specific exception before defaulting to the catchall error page (if provided).

• HTTP status code error page…
<error-page>
<error-code>404</error-code>
<location>/pageNotFoundErrorPage.jsp</location>
</error-page>

• The <location> MUST be relative to the web-app root/context,
which means it MUST start with a slash. (This is true regardless of whether
the error page is based on <error-code> or <exception-type>.)

• Note: This is only called when a 404 HTTP status code is encountered.
Also be aware that you CANNOT use <error-code> and <exception-type>
together (in the same <error-page> element). It's one or the other (by
exception type or error code).

• ANYTHING that extends Throwable can be declared in the <exception-type>
element – that includes java.lang.Error, runtime exceptions, and any checked
exceptions (so long as they are on the Container's classpath, of course).

• You MUST always use the fully qualified class name in the <exception-type>.

• You CAN generate error codes using response.sendError().There is no difference between Container-generated and programmer-generated HTTP errors.

(12)
Index.jsp
<html>
<body>
About to be bad...
<% int x = 10/0; %>
</body>
</html>

Myerror.jsp
<%@page isErrorPage="true" %>
<html>
<body>
<%out.println("This is an ArithmaticException");%>
</body>
</html>
Web.xml
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<error-page>
<exception-type>java.lang.ArithmeticException</exception-type>
<location>/Myerror.jsp</location>
</error-page>


</web-app>

(13)
Index.jsp
<html>
<body>
About to be bad...
<% int a[] = new int[4]; %>
<% out.println(a[4]); %>
<% int x = 10/0; %>
</body>
</html>
This is a my first java program to demostrame I want to explain this is so much
valuble for your life

Myerror.jsp
<%@page isErrorPage="true" %>
<html>
<body>
<%out.println("This is an ArrayIndexOutOfBoundsException");%>
</body>
</html>
Web.xml
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/Myerror.jsp</location>
</error-page>
</web-app>


(14)
Index.html
<html>
<body>
<% int a[] = new int[4]; %>
<% out.println(a[4]); %>
</body>
</html>


Myerror.jsp
<%@page isErrorPage="true" %>

<html>
<body>
<%out.println("This is my error page for code: 500");%>
</body>
</html>


Web.xml
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<error-page>
<error-code>500</error-code>
<location>/Myerror.jsp</location>
</error-page>
</web-app>

Learn PHP,JAVASRIPT,AJAX,MYSQL




PHP
1.
php.pdf

2.
PHP1.pdf

3.
PHP2.pdf

4.
PHP12.pdf

5..
phpwebdev.ppt

6.
wosd_0407_php.pdf

7.
Introducing-PDO.ppt

7.


MYSQL
1.
mysql.pdf

2.
phpmysql.pdf

3.
mysql.ppt

4.
uphpu-mysql.ppt

JAVASCRIPT

1.
JAVASCRIPT1.pdf

2.
JAVASCRIPT2.ppt

3.
JAVASCRIPT3.pdf

4.
JAVASCRIPT4.ppt

5.
JAVASCRIPT5.pdf

6.
JAVASCRIPT6.ppt

7.
JAVASCRIPT7.pdf

8.
JAVASCRIPT8.pdf

9.
JAVASCRIPT9.ppt

10.
JAVASCRIPT10.pdf

11.
JAVASCRIPT11.pdf

12.
JAVASCRIPT12.pdf

13.
JAVASCRIPT13.ppt

14.
JAVASCRIPT14.pdf

15.
JAVASCRIPT15.pdf

16.
JAVASCRIPT16.pdf

17.
JAVASCRIPT17.ppt

18.
JAVASCRIPT18.pdf

19.
JAVASCRIPT19.pdf

20.
JAVASCRIPT20.pdf

AJAX

1.
AJAX1.pdf

2.
AJAX2.ppt

3.
AJAX3.pdf

Sunday, November 8, 2009

Free SCJP (5.0-6.0) Mock Exams




1.
310-055d.pdf

2.
310-055-Q&A-Troytec.pdf

3.
SCJP Exam - 310-055.Exam.Q.and.A.12.06.05-BBL.pdf

4.
SCJP Exam - Java Certification Mock Exam.pdf

5.
310055test-Killer-kingExcept-Drag-n-Dropg
1.
310-055d.pdf

2.
310-055-Q&A-Troytec.pdf

3.
SCJP Exam - 310-055.Exam.Q.and.A.12.06.05-BBL.pdf

4.
SCJP Exam - Java Certification Mock Exam.pdf

5.
310055test-Killer-kingExcept-Drag-n-Dropg

My Java Video Tutorials...


Download Video Tutorials


1.
Learn Java the easy way!

2.
Top 40 Java Video Tutorials on youtube

3.
Java video tutorial

4.
Introduction to Java part1 rarl

5.
VTC-Java-6-Tutorials

6.
Complete Java Video Tutorials Courses

7.
JavaAppletSeries

8.
Eclipse and Java Video Tutorials

9.
Java Video Tutorial 4 If Statements

10.
How to use Java Web Start for your Java application

11.
java video tutorials - Rapidshare Files1.


MyJavaLibrary



Free download JAVA BOOKS

1.
SCJP Sun Certified Programmer for Java 6 (Exam 310-065).pdf

2.
Teach Yourself Java 6 in 21 Days 5th Ed.pdf

3.
Sun Certified Java Developer Study Guide.pdf

4.
McGraw-Hill - SCJP Sun Certified Programmer for Java 5 Study Guide (Exam 310-055) - 2006.chm

5.
servlets_and_JSP.pdf

6.
jsp_referance.pdf

7.
JSP best practices.pdf

8.
javaCodingStandards.pdf

9.
java_Testing_and_Design.pdf

10.
J2EETutorial.pdf

SCWCD(Sun Certified Web Component Developer) Exam books

11.
Manning.SCWCD.Exam.Study.Kit.Java.Web.Component.Developer.Certification.2nd.Edition.May.2005.pdf

12.
OReilly.Head.First.Servlets.and.JSP.2nd.Edition.Mar.2008.pdf

13.
Core J2EE Patterns.pdf

Followers

Search