Tuesday, May 25, 2010

Best eclipse plug-TOP 30

Original Source: http://www.tech-q.cn/thread-2630-1-1.html , slight changes.

1, PyDev - Python Development Environment for Eclipse : programmers can use the eclipse PyDev allows to develop Python, Jython and Iron Python application, and Pydev + eclipse has become a preferred development of Python IDE.

2, EasyEclipse for LAMP : EasyEclipse for LAMP is the Next one eclipse of the release (Translator's Note: that an independent program standalone). It is asked to support, such as PHP, Python, perl, and dynamic languages such as Ruby on Raiy development, and built-One web server, One Database, One CVS, One SVN.

3, UMLet - UML Tool for Fast UML Diagrams : UML tool that allows you to use UMLet lightweight, no pop-up interface for drawing UML diagram, you can quickly sketch; derived graph to pdf, eps, jpg, gif, svg, bmp, png and paste the system board; and Eclipse 3 + sharing plans; can customize their own graphics.

4, Spket IDE : Spket IDE is a very good One very powerful functional JavaScript and XML development tool set (Translator's Note: is an independent program standalone). It has developed JavaScript, XUL / XBL and Yahoo! Widget editor, which provides a JavaScript editor, such as code completion, syntax highlighting, outline and other features that can help developers to write efficient JavaScript code.

5, ATL : ATL (Atlas Transformation Language) atlas transformation language (PS: The first reaction is deformed language) is a model transformation language and tool set. In the MDE (Model-Driven Engineering) model-driven engineering fields, ATL provides a number of models from the original model to the target method. ATL IDE is eclipse Platform Direct package, integrates a number of standard development tools (syntax highlighting, debugger, etc.) The goal is to simplify the development of ATL difficult.

6, PTI - PHP Integration Tool : You may have seen this scene, in a website, there are many like PHPUnit or COdeSniffer that support PHP script development tools, and in addition, some IDEs, such as PDT (PHP Delepment Tools Project ) It has many powerful features, but it may not be used in the IDE environment, the tools that Web site. Then came PTI, PTI is a collection of eclipse plug-in, let it come to eliminate this defect it.

7, Skyway Builder Community Edition : Skyway Builder Community Edition is a code generation and build tools, suitable for applications that use Spring Framework. Spring MVC structure function allows users to type in a few minutes generated based on Spring, java CRUD application.

8, Bravo JSP Editor : Bravo JSP editor is a WYSIWYG (WYSIWYG) of the JSP / html editor.

9, Koders IDE Plugin for Eclipse : Koders Desktop IDE Plugins allow software developers can look at the eclipse development environment, source code (Translator's Note: This and the online download source which soon? doubt!)

10, Google Eclipse Search (GES) : GDS (Google Desktop Search) Google Desktop search engine integrated into IBM 'development environment to enhance the retrieval software projects, it becomes a GES (Google Eclipse Search) a.

11, Regex Util :
This plug-in to help programmers quickly create, use powerful regular expressions (regEx).

12, Emacs + : This plug-in in eclipse emacs editor to use simulation environment. (Such as Emacs really control it?)

13, AmaterasUML : AmaterasUML for drawing UML diagram, it supports class diagrams, sequence diagrams, use case diagram. But also to support such as importing class from eclipse workspace, interface, Java support, and, you can export the class diagram for the source file.

14, soapUI-Eclipse-plugin : soapUI is a desktop program that can based on SOAP / WSDL and REST / EADL of Web Services through HTTP to view, call, simulation, testing (functional testing, load testing). The main purpose of the developers / testers providing and web services client (java.net, etc.). (Original: It is mainly aimed at developers / testers providing and / or consuming web services (java,. Net, etc).) Soapui-eclipse-plugin provides a soapUI in all the available features, but adds some eclipse of the property; In the engineering view, the one soapUI Nature shows an integrated soapUI, simplifies the code generation wizard: soapUI perspective.

15, SMODL Development Suite : Smodl development kit will be quick, simple and agile model-driven development of web services from prototype to model the introduction of the source code or reverse engineering of years. If the model changes, corresponding to a large number of code generation, in order to keep pace. Built-in run-time engine can run on different platforms, providing soap, xml-rpc and json-rpc bindings for web services. Run-time dynamically generated WSDL to describe web services, strengthen the model in the definition of data consistency.

16, Notepad Eclipse Plugin : This plugin only purpose is to allow developers to write some minor notes, these notes are stored in the metadat years. (Translator's Note: this useful? Ye into the top30 in!)

17, Apache Directory Studio : Apache Directory Studio (formerly known as LDAP studio) is a complete tool platform used for any LDAP server, it is designed to be a special Apache Directory Server. Which of these plug-ins: a LDAP browser plug-ins; an LDIF Editor Plugin; a Schema Editor Plugin; a start in the Studio in Apache Directory Server plug-ins; a configuration Apache Directory Server plug-ins.

18, EHEP - Eclipse Hex Editor Plugin : (Translator note: logo too cottage, and as I do) EHEP really is a eclipse plugin, it provides a hex (16 decimal) mode to view, edit any file, and there is a table allows you to control character and hex mode.

19, Vaadin Plugin for Eclipse : Vaadin is open source, is used to create web user interface UI Fu library, with it, java developers can easily create some bright spots in the web application.

20, RMI Plugin for Eclipse : Genady's RMI Plug-in for Eclipse for the development of RMI program is already a very mature solution. In addition to auto-generate RMI's pile, but also simplifies the configuration process of the Java VM startup parameters, such as security policy, code base.

21, Lockness : Lockness for analyzing Java thread stack, with Lockness, can easily find the thread of the bottleneck or deadlock, the latest version of the updated JDK6 produce thread support.

22, Fast Fox : Fast Fox enhance your eclipseIDE, bring it to eclipse simple but still powerful mouse gestures. Usually it was used in the action, such as "return to the previous editor" (Translator's Note: shortcut keys ctrl + F6), "Close editor" (Translator's Note: shortcut keys ctrl + w), because you only need to is in accordance with the pie-shaped menu tips on it, and not spent a complex multi-click menu.

23, ExploreFS : This ultra-small plug-in (6k) The purpose is to get you to the local file manager to open the file containing the selected folder to view the selected file (Translator's Note: There is Similar eclipse plug-in easyexplorer). It packages view, resource view and the view of any file or class file to add the view in the right click menu "Open in File System". Particular it contains can be found. Class files jar package, compatible with Windows, Mac OS X, and Linux.

24, Saros - Distributed Pair Programming for Eclipse : Saros for special projects pair programming, it management cross-type document editing, one can support any number of participants. All members of the same session a unique eclipse project copy, Saros in the programming process to synchronize all of the copy.

25, RSS View : RSS View is an RSS / Atom reader, it is simple UI to be integrated into eclipse in your work area and co-exist. You can put everything here. By bugtracker, developer forums, wiki directly integrated into the RSS View where it can improve your development process. It also includes grouping, filtering information, read the source, offline reading of the source and some custom features.

26, Freemem : Freemem is to support eclipse graphical memory monitor.

27, EclipseColorer : Eclipse Coloreris for syntax highlighting, which supports more than 150 languages, has many powerful features, and a large number of languages, allow you to highlight some of the nested structure of the language (jsp, asp, php), support xml language.

28, Log4E : Log4E help you to easily in Java projects to create your own log management, major enhancements in: Log statements, special methods of entities in the log inserted, System out to simplify and explain the changes log.

Friday, May 21, 2010

JSP Implicit Objects

Implicit objects in jsp are the objects that are created by the container automatically and the container makes them available to the developers, the developer do not need to create them explicitly. Since these objects are created automatically by the container and are accessed using standard variables; hence, they are called implicit objects. The implicit objects are parsed by the container and inserted into the generated servlet code. They are available only within the jspService method and not in any declaration. Implicit objects are used for different purposes. Our own methods (user defined methods) can't access them as they are local to the service method and are created at the conversion time of a jsp into a servlet. But we can pass them to our own method if we wish to use them locally in those functions.

There are nine implicit objects. Here is the list of all the implicit objects:


Object Class
application javax.servlet.ServletContext
config javax.servlet.ServletConfig
exception java.lang.Throwable
out javax.servlet.jsp.JspWriter
page java.lang.Object
PageContext javax.servlet.jsp.PageContext
request javax.servlet.ServletRequest
response javax.servlet.ServletResponse
session javax.servlet.http.HttpSession


Application: These objects has an application scope. These objects are available at the widest context level, that allows to share the same information between the JSP page's servlet and any Web components with in the same application.
Config: These object has a page scope and is an instance of javax.servlet.ServletConfig class. Config object allows to pass the initialization data to a JSP page's servlet. Parameters of this objects can be set in the deployment descriptor (web.xml) inside the element . The method getInitParameter() is used to access the initialization parameters.
Exception: This object has a page scope and is an instance of java.lang.Throwable class. This object allows the exception data to be accessed only by designated JSP "error pages."
Out: This object allows us to access the servlet's output stream and has a page scope. Out object is an instance of javax.servlet.jsp.JspWriter class. It provides the output stream that enable access to the servlet's output stream.
Page: This object has a page scope and is an instance of the JSP page's servlet class that processes the current request. Page object represents the current page that is used to call the methods defined by the translated servlet class. First type cast the servlet before accessing any method of the servlet through the page.
Pagecontext: PageContext has a page scope. Pagecontext is the context for the JSP page itself that provides a single API to manage the various scoped attributes. This API is extensively used if we are implementing JSP custom tag handlers. PageContext also provides access to several page attributes like including some static or dynamic resource.
Request: Request object has a request scope that is used to access the HTTP request data, and also provides a context to associate the request-specific data. Request object implements javax.servlet.ServletRequest interface. It uses the getParameter() method to access the request parameter. The container passes this object to the _jspService() method.
Response: This object has a page scope that allows direct access to the HTTPServletResponse class object. Response object is an instance of the classes that implements the javax.servlet.ServletResponse class. Container generates to this object and passes to the _jspService() method as a parameter.
Session: Session object has a session scope that is an instance of javax.servlet.http.HttpSession class. Perhaps it is the most commonly used object to manage the state contexts. This object persist information across multiple user connection.
-----------------------------------------
<% // Check if attribute has been set Object o = pageContext.getAttribute("com.mycompany.name1", PageContext.PAGE_SCOPE); if (o == null) { // The attribute com.mycompany.name1 may not have a value or may have the value null } // Save data pageContext.setAttribute("com.mycompany.name1", "value0"); // PAGE_SCOPE is the default pageContext.setAttribute("com.mycompany.name1", "value1", PageContext.PAGE_SCOPE); pageContext.setAttribute("com.mycompany.name2", "value2", PageContext.REQUEST_SCOPE); pageContext.setAttribute("com.mycompany.name3", "value3", PageContext.SESSION_SCOPE); pageContext.setAttribute("com.mycompany.name4", "value4", PageContext.APPLICATION_SCOPE); %>

<%-- Show the values --%>
<%= pageContext.getAttribute("com.mycompany.name1") %> <%-- PAGE_SCOPE --%>
<%= pageContext.getAttribute("com.mycompany.name1", PageContext.PAGE_SCOPE) %>
<%= pageContext.getAttribute("com.mycompany.name2", PageContext.REQUEST_SCOPE) %>
<%= pageContext.getAttribute("com.mycompany.name3", PageContext.SESSION_SCOPE) %>
<%= pageContext.getAttribute("com.mycompany.name4", PageContext.APPLICATION_SCOPE) %>

JSP implicit objects

JSP implicit objects
6.5) Given a design goal, write JSP code using the appropriate implicit objects:
(a) request,
(b) response,
(c) out,
(d) session,
(e) config,
(f) application,
(g) page,
( h) pageContext, and
(i) exception.
What are Implicit Objects?When writing Servlets the available objects are fairly obvious as they are the parameters to methods, thus if you are overriding the doPost method you will have a signature of
public void doPost(HttpServletRequest request,
HttpServletResponse response)
When writing JSP pages the implicit objects are created automatically for you within the service method . You just have to know what the implicit objects are, but as most of them match closely to those available in Servlet methods they are not too difficult to memorise. You will have come across one of the implicit objects already with the out object which allows you to send information to the output stream.
Note that the implicit variables are only available within the jspService method and thus are not available within any declarations. Thus for example the following code will cause a compile time error.
<%! public void amethod(){ out.print("Hello"); } %>
The request and response implicit objects The request implicit object is an instance of HttpServletRequest, and response is an instance of HttpServletResponse objects. They are available in a similar way to the request and response object passed to the doGet and doPost methods in servlets.
A typical use for the request is to get the details of HTTP query string such as query names and parameters.
<%= request.getQueryString() %>
Will display the query string after the name of the jsp file itself. Thus if this code is within a file called hello.jsp and is called with the url as follows
http://localhost:8080/chap03/hello.jsp?thisisthequerystring
The output will include thisisthequerystring as part of the page.
The response can be used for the same purposes as the HttpServletResponse in a servlet, such as adding cookies or headers.
The request and response objects are the same as the parameters to doPost and represent instances of HttpServletRequest and HttpServletResponse respectively.
The out implicit object The out implicit object has a type of jsp.JspWriter. The out object can be used in a similar way to System.out is used in plain ordinary Java programs, i.e.
<% out.print("Hello World"); %>
The parameters of out are sent to the output stream, which generally means they end up visible in the browser requesting the JSP page.
sessionThe session implicit object is an instance of
javax.servlet.http.HttpSession
The session concept is a way of allowing multiple requests from the same client to be group together as part of a single “conversation”. This is a way of getting around the basic architectural limitation within HTTP in that it was designed as a stateless protocol, i.e. web servers “forget” about each client as soon as a request has finished execution. The default way of logically linking multiple requests from the same client is by generating a cookie that stores a value unique to the client. After the first request establishes a session, each subsequent request reads that cookie and can thus identify the unique client.
With the session object you do not need the type of code required in a Servlet whereby you have to call the getSession method to access an existing session or start a new one. Typical uses of the session object are for getting and setting attributes. Thus you can add a new attribute to the session with code like the following.
<% session.setAttribute("username","marcusgreen"); %>
config The config implicit object is an instance of
javax.servlet.ServletConfig
And represents the parameters set up within the deployment descriptor. To set up the configuration a servlet is configured within web.xml , but instead of creating a element a element is created containing the name of the JSP page. Parameters are then created using the and tags.
The config object can be used to retrieve parameters using its
getInitParameter(String param)
method.
The config object can be used to retrieve the ServletContext object through its getServletContext method. Thus the following code retrieves information about the currently executing server, and in my own setup it generates the output.
Apache Tomcat/5.5.9
<% ServletContext ct = config.getServletContext(); out.print(ct.getServerInfo()); %>
application The application implicit object is an instance of javax.servlet.ServletContext. It refers to the overall web application environment that the JSP belongs to. According to the API docs
“Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file.”
In Apache Tomcat a web application will be contained in an individual directory under the webapps directory. A typical use of the application object is to get access to the application wide initialisation parameters. Because the application and config objects have similar and slightly confusing uses the following code shows how they can be used along with a deployment descriptor (WEB.XML) that sets up the appropriate initialisation parameters for them.
The file index.jsp
<% /*for parameters declared at the application level . *i.e. under the WEB-APP tag of the deployment descriptor */ out.print(application.getInitParameter("myparam")); /*for a specific resource within an application *identified as a servlet in the deployment descriptor */ out.print(config.getInitParameter("myparam2")); %>

The deployment descriptor (WEB.XML)



myparam param1



MyServlet


/index.jsp


myparam2 param2




MyServlet


/index.jsp



The page implicit object The page implicit object is of type Object and it is assigned a reference to the servlet that executing the _jspService() method. Thus in the Servlet generated by tomcat the page object is created as
Object page = this;

Because page is of type Object it is of less direct use than simply accessing the implicit this object. To access any of the methods of the servlet through page it must be first cast to type Servlet. Thus the two following lines of code are equivalent.
<% this.log("log message"); %>
<% ((HttpServlet)page).log("anothermessage"); %>

As you probably will not be using the page object in your own code the main thing to remember for the exam is that it is not the same as the pageContext object and that it is of type Object.
The pageContext implicit object The pageContext object has a type of javax.servlet.jsp.PageContext and according to the API documents
“A PageContext instance provides access to all the namespaces associated with a JSP page, provides access to several page attributes, as well as a layer above the implementation details. Implicit objects are added to the pageContext automatically “http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/jsp/PageContext.html
So it can be seen as a convenience object for tasks such as transferring requests to other web resources. Much of its functionality appears to be for the convenience of generating the servlet from the JSP, thus the following example of a servlet generated from the Tomcat container shows how PageContext is used to populate other implicit objects.
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
A typical use of the pageContext is to to include another resource or forward to another resource. Thus the following would forward from the current page to menu.jsp
<% pageContext.forward("menu.jsp"); %>
The exception implicit object The exception implicit object is of type
java.lang.Throwable
This object is only available to pages that have isErrorPage set to true with the directive
<%@ page isErrorPage='true' %>
The exception object refers to the exception triggered by the page that uses this page as an exception handler
The following code demonstrates the use of the exception implicit object. The first page uses the errorPage directive to set up the JSP page to use when an error occurs, and the second page called ErrorPage.jsp uses the isErrorPage directive to set itself up to catch the error.
First page
<%@page errorPage="ErrorPage.jsp" %>
<% int i=10; /*Divide by zero, generates an error */ out.print(i/0); %>

ErrorPage.jsp
<%@ page isErrorPage='true' %>
<% out.print("

Here is the error message

");
out.print(exception.getMessage());
%>
Declarative handling of exceptionsIt is also possible to map HTTP error codes and or Java exception types to an error page in the deployment descriptor. This is done at the web application level by using the tag which is a child of the tag. Thus the following tags would re-direct all SQL exception errors to the /errorpage.jsp page.


java.sql.SQLException


/errorpage.jsp



The following tags would re-direct all HTTP 404 errors to the /errorpage.jsp page

404
/errorPage.jsp

Friday, May 7, 2010

cal age !!

private static int age(int y, int m, int d) {
Calendar cal = new GregorianCalendar(y, m, d);
Calendar now = new GregorianCalendar();
int res = now.get(Calendar.YEAR) - cal.get(Calendar.YEAR);
if((cal.get(Calendar.MONTH) > now.get(Calendar.MONTH))
|| (cal.get(Calendar.MONTH) == now.get(Calendar.MONTH)
&& cal.get(Calendar.DAY_OF_MONTH) > now.get(Calendar.DAY_OF_MONTH)))
{
res--;
}
return res;
}
---------------------------------------------
import java.util.*;
import java.io.*;

public class AgeCalculation{
public static void main(String[] args) throws IOException{
int day = 1, month = 0, year = 1, ageYears, ageMonths, ageDays;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
Calendar cd = Calendar.getInstance();
try{
System.out.print("Enter year of your date of birth : ");
year = Integer.parseInt(in.readLine());
if(year > cd.get(Calendar.YEAR)){
System.out.print("Invalid date of birth.");
System.exit(0);
}
System.out.print("Enter month of your date of birth : ");
month = Integer.parseInt(in.readLine());
if(month < 1 || month > 12){
System.out.print("Please enter monthe between 1 to 12.");
System.exit(0);
}
else{
month--;
if(year == cd.get(Calendar.YEAR)){
if(month > cd.get(Calendar.MONTH)){
System.out.print("Invalid month!");
System.exit(0);
}
}
}
System.out.print("Enter day of your date of birth : ");
day = Integer.parseInt(in.readLine());
if(month == 0 || month == 2 || month == 4 || month == 6 || month == 7 ||
month == 9 || month == 11){
if(day > 31 || day < 1){ System.out.print("Please enter day between 1 to 31."); System.exit(0); } } else if(month == 3 || month == 5 || month == 8 || month == 10){ if(day > 30 || day < 1){ System.out.print("Please enter day between 1 to 30."); System.exit(0); } } else{ if(new GregorianCalendar().isLeapYear(year)){ if(day < 1 || day > 29){
System.out.print("Please enter day between 1 to 29.");
System.exit(0);
}
}
else if(day < 1 || day > 28){
System.out.print("Please enter day between 1 to 28.");
System.exit(0);
}
}
if(year == cd.get(Calendar.YEAR)){
if(month == cd.get(Calendar.MONTH)){
if(day > cd.get(Calendar.DAY_OF_MONTH)){
System.out.print("Invalid date!");
System.exit(0);
}
}
}
}
catch(NumberFormatException ne){
System.out.print(ne.getMessage() + " is not a legal entry!");
System.out.print("Please enter number.");
System.exit(0);
}
Calendar bd = new GregorianCalendar(year, month, day);
ageYears = cd.get(Calendar.YEAR) - bd.get(Calendar.YEAR);
if(cd.before(new GregorianCalendar(cd.get(Calendar.YEAR), month, day))){
ageYears--;
ageMonths = (12 - (bd.get(Calendar.MONTH) + 1)) + (bd.get(Calendar.MONTH));
if(day > cd.get(Calendar.DAY_OF_MONTH)){
ageDays = day - cd.get(Calendar.DAY_OF_MONTH);
}
else if(day < cd.get(Calendar.DAY_OF_MONTH)){ ageDays = cd.get(Calendar.DAY_OF_MONTH) - day; } else{ ageDays = 0; } } else if(cd.after(new GregorianCalendar(cd.get(Calendar.YEAR), month, day))){ ageMonths = (cd.get(Calendar.MONTH) - (bd.get(Calendar.MONTH))); if(day > cd.get(Calendar.DAY_OF_MONTH))
ageDays = day - cd.get(Calendar.DAY_OF_MONTH) - day;
else if(day < cd.get(Calendar.DAY_OF_MONTH)){
ageDays = cd.get(Calendar.DAY_OF_MONTH) - day;
}
else
ageDays = 0;
}
else{
ageYears = cd.get(Calendar.YEAR) - bd.get(Calendar.YEAR);
ageMonths = 0;
ageDays = 0;
}
System.out.print("Age of the person : " + ageYears + " year, " + ageMonths +
" months and " + ageDays + " days.");
}
}