eclipse java web configuration

----------------------------------------??? Java_ee_sdk-5_07-jdk-6u16 -windows.exe + tomcat 6

http://cds-esd.sun.com/ESD6/JSCDL/java_ee_sdk / 5u7-6u16-ml/java_ee_sdk-5_07-jdk-6u16-windows.exe? AuthParam = 1257127940_90bf6ab30b793fdc95a0a8b75ec3881b & TicketId = nod3BVAYR3B9lOAglUOUU5% 2BddA% 3D% 3D & GroupName = CDS & FilePath = / ESD6/JSCDL/java_ee_sdk/5u7-6u16-ml/java_ee_sdk-5_07-jdk-6u16-windows.exe & File = java_ee_sdk-5_07-jdk-6u16-windows.exe

----------------------------------- J2SDK [jdk-6u13-windows-i586-p] and TOMCAT5. 5 of the installation and configuration [attached apache-tomcat5 Download]

Step One: Download j2sdk 【jdk-6u13-windows-i586-p.exe】 and tomcat: to the sun official site

http://tomcat.apache.org/

http://java.sun.com/javase/downloads/index.jsp

ftp://mask-student.wsisiz.edu.pl/pub/pc/pozyteczne oprogramowanie/java/stare/jdk-6u13-windows-i586-p.exe

【Latest jdk 1.5 jdk-6u13-windows-i586-p.exe】, tomcat 5.5, jdk1.4 or above recommended, tomcat4.0 above the second step: to install and configure your j2sdk and tomcat: implementation of the j2sdk and tomcat installation program, and then set in accordance with the path can be installed.
1. Install j2sdk later, need to configure the environment variables look in My Computer -> Properties -> Advanced -> Environment Variables -> System Variables, add the following environment variables (assuming your j2sdk installed in c: \ j2sdk1.4.2):
JAVA_HOME = c: \ j2sdk1.4.2
classpath =.;% JAVA_HOME% \ lib \ dt.jar;% JAVA_HOME% \ lib \ tools.jar; (.; must not be less, because it represents the current path)
path =% JAVA_HOME% \ bin

Then you can write a simple java program to test J2SDK is installed successfully:
public class Test (
public static void main (String args []) (
System.out.println ("This is a test program.");
)
)
The above procedure will save this file as a file named Test.java.
Then open a command prompt window, cd to the directory where your Test.java, and then type the following command
javac Test.java
java Test
At this point, if you see printed This is a test program. Then you're done, if not print out this sentence, you need to carefully check your configuration.

2. After installing Tomcat, in My Computer -> Properties -> Advanced -> Environment Variables -> System Variables, add the following environment variables (assuming your tomcat installed in c: \ tomcat):
CATALINA_HOME: c: \ tomcat
CATALINA_BASE: c: \ tomcat
TOMCAT_HOME: C: \ Tomcat
And then modify the environment variable in the classpath, the tomat installation directory common \ lib under the servlet.jar to the classpath in additional to, the modified classpath is as follows:
classpath =.;% JAVA_HOME% \ lib \ dt.jar;% JAVA_HOME% \ lib \ tools.jar;% CATALINA_HOME% \ common \ lib \ servlet.jar;
Then you can start tomcat, in IE to access http://localhost:8080 , if the tomcat welcome page to see if install succeeded.
Third step: create your own jsp app directory
1. To the Tomcat installation directory of the webapps directory, you can see ROOT, examples, tomcat-docs like Tomcat that comes with the catalog;
2. In the webapps directory, create a directory named myapp;
3.myapp create a directory under WEB-INF, note the directory name is case-sensitive;
4.WEB-INF create a file under the web.xml, as follows:
<? Xml version = "1.0" encoding = "ISO-8859-1"?>

<! DOCTYPE web-app
PUBLIC "- / / Sun Microsystems, Inc. / / DTD Web Application 2.3 / / EN"
" http://java.sun.com/dtd/web-app_2_3.dtd ">

<web-app>
<display-name> My Web Application </ display-name>
<description>
A application for test.
</ Description>
</ Web-app>
5. Myapp a test under the new jsp page, the file named index.jsp, file reads as follows:
<html> <body> <center>
Now time is: <% = new java.util.Date ()%>
</ Center> </ body> </ html>
6. Restart Tomcat
7. Open your browser, enter the http://localhost:8080/myapp/index.jsp see the current time, then shows a success.
Step Four: Create your own Servlet:
Write your first Servlet
import java.io. *;
import javax.servlet .*;
import javax.servlet.http .*;
public class HelloWorld extends HttpServlet
(
public void doGet (HttpServletRequest request, HttpServletResponse response) th
rows ServletException, IOException
(
response.setContentType ("text / html");
PrintWriter out = response.getWriter ();
out.println ("<html> <head> <title>");
out.println ("This is my first Servlet");
out.println ("</ title> </ head> <body>");
out.println ("<h1> Hello, World! </ h1>");
out.println ("</ body> </ html>");

)
)
Then still use the javac HelloWorld.java to compile this file, if there is no import javax.servlet .*
So that should be C: \ Tomcat \ common \ lib inside the servlet.jar file copied to the C: \ JDK \ jre \ lib \ e
xt, the re-compiled, no problem!
Then in the Tomcat directory inside the C: \ Tomcat \ webapps \ ROOT inside the file structure as follows:
ROOT \ index.html
ROOT \ welcom.jsp
ROOT \ WEB-INF \ lib \ MyServlet.jar (If your servlet's. Class to play has become. Jar file, then on the lib below)
ROOT \ WEB-INF \ classes \ HelloWorld.class (to top generate HelloWorld.class file on the inside)
Then enter in your browser http://localhost:8080/servlet/HelloWorld , then Server welcomed by the error of: Error 404 - Not Found
How going on?
Servlet must use the C: \ Tomcat \ webapps \ ROOT \ WEB-INF web.xml file in this directory the following register
Open the web.xml file with the EP,

To following this procedure
<! - [If! SupportLineBreakNewLine] ->
<! - [Endif] ->

<servlet>

<servlet-name> org.apache.jsp.index_jsp </ servlet-name>

<servlet-class> org.apache.jsp.index_jsp </ servlet-class>

</ Servlet>

<servlet-mapping>

<servlet-name> org.apache.jsp.index_jsp </ servlet-name>

<url-pattern> / index.jsp </ url-pattern>

</ Servlet-mapping>
Replaced
<servlet>
<servlet-name> HelloWorld </ servlet-name>
<servlet-class> HelloWorld </ servlet-class>
</ Servlet>
<servlet-mapping>
<servlet-name> HelloWorld </ servlet-name>
<url-pattern> / servlet / HelloWorld </ url-pattern>
</ Servlet-mapping>
If not, add that code directly

Why?
Because such a structure
<servlet>
<servlet-name> HelloWorld </ servlet-name>
<servlet-class> HelloWorld </ servlet-class>
</ Servlet>
That contains the servlet class specified.
The following structure
<servlet-mapping>
<servlet-name> HelloWorld </ servlet-name>
<url-pattern> / servlet / HelloWorld </ url-pattern>
</ Servlet-mapping>
That should be mapped out what it designated HelloServlet URL pattern.
After completion of the modified web.xml, restart the Server, and then re-enter http://localhost:8080/servlet/HelloWorld , so huge a Hello, World! etc.

http://localhost:8080/index.jsp

------------------------------------ 1 eclipse the various download versions

eclipse-java java development general use. 92M-free pure java development web development, then recommend the first one, plug-less, the speed and resource consumption will be less.
eclipse-jee JavaEE direction can use this version. 189M for web development without taking into account the speed and memory, there is no difference between the first two.
eclipse-modeling plug-in development and modeling.
eclipse-rcp RCP development.
eclipse-reporting this is not clear to see the name of estimates made statements. 219M
Eclipse-SDK [ Eclipse Classic ] this is equivalent to the standard version, can do a general plug-in development, and java development. 162M-free web development

------------------------------------ 2 eclipse configuration

1 Configure JREs

Open the configuration dialog
preferences - java-installed jres
In the pop-up dialog box to select your installed JDK6

standard VM
C: \ jdk1.6.0_13

After clicking OK you can repeat the above action, add JRE6

2 Configure Tomcat

preferences --- server-installed runtime enironment - add

In the following dialog box that opens, select Tomcat 5.5

Choose your address bar in the Tomcat Tomcat installation directory, in the JRE column selection JDK1.6.0, Tomcat startup time in the future, if prompted

JRE configuration errors, can be modified to be back here. Click Finish.

New java web project:

File - New-OTHER-web-dynamic web project

3 Import Export

Import:
file-import: general-existing projects into workspace

General can import folders and zip archive, etc.

Export war:

To turn off tomcat,

Right Projects> Export - war file, and then the war Export pop-up dialog box, select the Destination directory for the webapp, and then click the Finish button.
Open the tomcat, in ie you can access the changed item, **. war will automatically extract into a directory for the tomcat access

4 Show Line Numbers

Window> Preferences ... to open the Preferences Settings dialog box, almost all of Eclipse's settings options can be found here. To display line numbers, you can expand the node General> Editors> Text Editors, Show Line Numbers

5, source code formatting

Sometimes confused handwritten code, this time can first select to format code (do not choose to format the current document is all the code), by selecting the menu Source> Format or right-click in the editor, select menu Source> Format

6 getter and setter methods generated

Often when writing to write a JavaBean template of the getXXX () and setXXX () this way, we can use Eclipse to automatically generate the template-based approach. First written private String name;, then select the Source> Generate Getters and Setters ... or right-click in the editor, select menu Source> Generate Getters and Setters ... you can open the Generate Getters andSetters dialog box, in the dialog box, select Build method, and then click OK button.

7 automatically generated constructor

Recommended first define the variables, source generate constructor with fields

8 Notes and uncomment

Ctrl + /

9 eclipse custom library:
windows - java - Build path - user Libraries --- new: user library name to hibernate, do not check the system library; select hibernate, "Add JARs", into Hibernate, JDBC package, OK

A custom library for the project:
Right project - properties - java build path - libraries - add library - user library, select the database we can build the hibernate

------------------------------------ 3 eclipse error

http://hi.baidu.com/lalalove_yaya/blog/item/d4e9096011c09ad68cb10d2e.html

1 problem occurred

unhandled event loop exception

permgen space

PermGen space full name is the Permanent Generation space, refers to the memory of the permanent preservation areas OutOfMemoryError: PermGen space memory benefits from the surface is out, the solution also must increase the memory.

Solution eclipse.ini:

-Vmargs: Description of parameters followed by the VM
-Xms128m: Virtual Machine occupy the minimum system memory
-Xmx512m: virtual machine system, the maximum memory occupied 5% of 25.6M, the theory goes-Xmx value with the-XX: MaxPermSize
Must be greater than 25.6M
-XX: PermSize: minimum heap size. General reported that memory is low, are saying that this is too small
Heap space will be less than 5% remaining warning, proposed to set up a little
Great point, but depending on your machine to set the memory size
-XX: MaxPermSize: maximum heap size. This also has more appropriate

To change the parameters inside
-Vmargs
-Xms128M
-Xmx512M
-XX: PermSize = 128M
-XX: MaxPermSize = 256M

2 java.lang.OutOfMemoryError: Java heap space

----------------------------------------------- 4 mysql- connector-java [attached download]

Download the jar to connect mysql package, such as: mysql-connector-java-5.0.4-bin.jar, the jar package to your project.
The following is a link code

Build java files
import java.sql.DriverManager;
public class test (

/ **
* @ Param args
* /
public static void main (String [] args) (
/ / TODO Auto-generated method stub
try
(
Class.forName ("com.mysql.jdbc.Driver");
System.out.println ("Success loading MySQL Driver ...");
)
catch (Exception ex)
(
System.out.println ("Error loading MySQL Driver ...");
ex.printStackTrace ();
)
try (
Object conn = DriverManager.getConnection ("jdbc: mysql: / / localhost: 3306/zfblog? User = root & password = 123456");
System.out.println ("Success connect Mysql Database!");
)
catch (Exception e)
(
e.printStackTrace ();
)
)

)

1 Right-project-properties for --- java build path --- libraries: add txternal jars
2 If your project is a tomcat project, the mysql-connector-java-3.1.13-bin.jar in this package, this package into the WEB-INF \ lib and then right the jar under the package -> build path-> add to build path manually to the jar package to your project
3 or the jar package into the tomcat installation directory \ common \ lib Next, put it here, all the eclipse of the project can share this jar package

----------------------------------------------- 5 xml configuration explain

<! - Specify the index page ->
<welcome-file-list>
<welcome-file> index.jsp </ welcome-file>
<welcome-file> index.html </ welcome-file>
</ Welcome-file-list>

<! - The specified error page ->
<error-page>
<error-code> 404 </ error-code>
<location> / NotFound.jsp </ location>
</ Error-page>
<error-page>
<exception-type> exception.ServletNotFound </ exception-type>
<location> / sorry.jsp </ location>
</ Error-page>

<servlet>
<description> </ description>
<display-name> AdminLoginServle </ display-name>
<servlet-name> AdminLoginServle </ servlet-name>
<servlet-class> soyo.shopping.servlet.admin.LoginServle </ servlet-class> --- servlet-class
</ Servlet>
<servlet-mapping> - URL pattern in the Servlet and define a mapping between
<servlet-name> AdminLoginServle </ servlet-name> --- <servlet-name> Servlet given element name must be declared in the <servlet> element in the Servlet name
<url-pattern> / admin / AdminLoginServle </ url-pattern> ----< url-pattern> element specifies the URL corresponding to Servlet path, the path is relative to the Web application context path root
</ Servlet-mapping>

----------------------------------------------- 6 modify tomcat Main Menu

Open the C: \ Tomcat \ conf \ server.Xml, in <host> </ host> adding between Code: China Network Management Alliance www.bitscn.com
<Context Path="" docBase="E:\workspace_eclipse_java" debug="0" reloadable="true" crossContext="true"/>
This restart tomcat
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of eclipse java web configuration

  • hibernate (jpa) composite primary key annotation statement Ways

    In the design of the database tables are designed with a composite primary key of the table, that table's record by more than one field joint identification, such as: Table CREATE TABLE TB_HOUR_DATA ( STAT_DATE DATE NOT NULL, PATH_ID NUMBER(20) NOT NULL,

  • EJB ant script to deploy template works

    <? xml version = "1.0" encoding = "UTF-8"?> <! - Name Project name basedir build.xml file directory -> <project name="HelloWorld" basedir="."> <! - Property variables -> <! - The sour ...

  • log4j easy application in java

    JAVA development, frequently used the log output, in a so-called most of the software company will have its own set of configuration style, re-read the configuration file to initialize property of the log, it will be good, but sometimes may not need to fu

  • java read file

    java read documents in two ways: java.io and java.lang.ClassLoader When using the java.io, when java.lang.ClassLoader use it? (Note: If prior to read xml file java read file clearly aware of these two methods have been like! Can take much less to understa

  • spring myfaces hibernate richfaces

    1.web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" 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/j

  • Process migration from tomcat to websphere changes

    Process migration from tomcat to websphere changes Because customers use the web application server software used by different what tomcat5, tomcat6, websphere5.1, websphere6.1, weblogic8, and so on, and the software used inconsistent standards, ibm's

  • JAVA EE JSP_JNDI

    dsfdsa http://lindows.javaeye.com/admin/blogs/213348 Tomcat 6 with the connection pool data source configuration http://www.blogjava.net/ec2008/archive/2008/07/19/216063.html project: test Driver path: D: \ workspace \ test \ WebRoot \ WEB-INF \ lib ...

  • The EJB3 Persistence

    EJB3 persistence with Hibernate is very similar to the mechanism: Environment: Server: JBOSS5.0 Database: MySQL5.0 1. Set up a data source First of all, in jboss-5.0.0.GA \ server \ default \ deploy, the establishment of a database used to connect the dat

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • First Hibernate Example

    Curd a simple example. Source does not contain the dependent libraries, or playing too much of the package. PO object Note: One must have the default constructor 2 non-final modified. Otherwise useless lazy loading. UserDAOImpl category code, and other co

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries