Recent Notes

Displaying notes 11 - 20
Created by Dr. Xi on February 12, 2010 22:52:27
For Tomcat 6, there's no default manager username and password. You do have to set it up yourself, though it's pretty straightforward. The Tomcat manager webapp is restricted to users with a role named manager . So you'll need to create a user and assign the manager role to it. Edit $CATALINA_BASE/conf/tomcat-users.xml to read: <?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required ...
Created by Dr. Xi on February 12, 2010 22:39:15
When you start Tomcat for the first time, you may get the "port 8080 is already in use" error. Indeed, port 8080 is commonly used by a lot of development servers by default (Oracle XE for another example). Luckily, it's quite easy to ask Tomcat to use a different port. I use port 8086, which is a natural next step and superior to 8080. Simply edit $CATALINA_BASE/conf/server.xml and change 8080 to 8086: <!-- A "Connector" represents an endpoint by which requests are received and responses are returned. Documentation at : Java HTTP Connector: /docs/config/http.html (blocking & non-blocking) Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html Define a non-SSL HTTP/1.1 Connector on port 8080 --> <Connector port="8086" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> If you have not configured ...
Created by Dr. Xi on February 11, 2010 05:07:48    Last update: February 11, 2010 05:08:20
On Linux, you can use the fuser command to find out who has a file open, or is using a port. For example, if you start Tomcat and get the error "Address already in use: 8080", you want to know which process is already binding to port 8080. # list processes on port 8080 fuser 8080/tcp # verbose mode fuser -v 8080/tcp # kill the processes accessing port 8080 fuser -k 8080/tcp # show all processes at the (local) TELNET port fuser telnet/tcp # list processes using /mnt/usb1 with user name fuser -m -u /mnt/usb1 # list process IDs and user names for processes using the current directory fuser -fu .
Created by meiu on February 11, 2010 04:34:48
Bring up the System Properties dialog by pressing Windows Logo + Pause/Break . Select the Advanced tab. Click the "Environment Variables" button. Create a new environment variable by clicking New . Edit an existing one by clicking Edit . User specific variables are on the top. System wide variables (effective for all users) are at the bottom.
Created by Dr. Xi on February 11, 2010 00:39:57
The <taglib> element is no longer needed in web.xml since JSP 2.0. Since the location of TLD files are not specified, the servlet container searches for them in these places: Under the /WEB-INF folder Sub folders of the /WEB-INF folder Inside JAR files under /WEB-INF/lib - in the META-INF folder inside the JAR. Usually the TLD files are packaged with the tag library class files in the same JAR. For example, the TLD files for the standard JSTL tags can be found in standard.jar/META-INF . How do you use a custom tag in a JSP then? You use the same uri as declared in the TLD in the taglib declaration of your JSP. For example, the JSTL core tags TLD ( c.tld ) looks like ...
Created by Dr. Xi on February 11, 2010 00:04:02
Servlet container initializes this servlet when it starts up. The content of this element must be a positive integer indicating the order in which the servlet should be loaded. Lower integers are loaded before higher integers. If no value is specified, or if the value specified is not a positive integer, the servlet can be loaded in any order in the startup sequence. In this example, Struts is loaded before cms: <!-- Struts action servlet setup --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- All .do requests go to struts --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <servlet> <servlet-name>cms</servlet-name> <servlet-class>com.example.ContentManagementSystem</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <!-- *.cms pages are handled by the cms servlet --> <servlet-name>cms</servlet-name> <url-pattern>*.cms</url-pattern> </servlet-mapping>
Created by Dr. Xi on February 10, 2010 23:48:23    Last update: February 10, 2010 23:49:13
Servlet mapping examples in web.xml. Struts: <!-- Struts action servlet setup --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- All .do requests go to struts --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> Spring: <servlet> <servlet-name>springapp</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- All .htm requests go to Spring --> <servlet-mapping> <servlet-name>springapp</servlet-name> <url-pattern>*.htm</url-pattern> </servlet-mapping> JSF myfaces: <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- All .faces requests go to JSF --> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.faces</url-pattern> </servlet-mapping>
Created by Dr. Xi on February 10, 2010 23:39:37
Example web.xml that includes most frequently used elements. This sample is for Servlet Specification 2.4. <?xml version="1.0" encoding="UTF-8"?> <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"> <!-- Appliocation name and description --> <display-name>Example App</display-name> <description>A web.xml example</description> <!-- Set session timeout to 30 minutes --> <session-config> <session-timeout>30</session-timeout> </session-config> <!-- Context parameters --> <context-param> <description>Enable debugging for the application</description> <param-name>debug</param-name> <param-value>true</param-value> </context-param> <context-param> <description>Web master email</description> <param-name>webmaster</param-name> <param-value>webmaster@example.com</param-value> </context-param> <!-- Servlets --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- Servlet mappings --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- Filters --> <filter> <filter-name>loggingFilter</filter-name> <filter-class>com.example.LoggingFilter</filter-class> <init-param> <param-name>appender</param-name> <param-value>com.example.FileAppender</param-value> </init-param> <init-param> <param-name>logging-file</param-name> <param-value>/var/logs/myapp.log</param-value> </init-param> </filter> <!-- Filter mapping --> <filter-mapping> <filter-name>loggingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- Application events listener --> <listener> <listener-class>com.example.listener.ContextListener</listener-class> </listener> <!-- Session events listener --> <listener> <listener-class>com.example.listener.SessionListener</listener-class> </listener> ...
Created by meiu on February 10, 2010 20:53:27
Step by step procedure to setup OC4J server for Eclipse. Version used is Galileo for Java EE Developers. Initialize OC4J You'll be asked to create a password the first time you run the standalone OC4J server. You need to remember this password and use it in the Eclipse setup. In the following C:\jdev1013_5 is where the JDeveloper suite is installed. cd C:\jdev1013_5\j2ee\home java -jar oc4j.jar Add Server Runtime Environment Go to Windows menu, bring up the Preferences dialog. Select Server -> Runtime Environments, click Add. Select Oracle OC4J Standalone 10.1.3.n, click Next. Enter J2EE home and click Finish. Add a server for OC4J Go to Windows menu, select Show View -> Servers. If Servers menu is not visible, select Other and enter "servers" in the ...
Created by Dr. Xi on February 09, 2010 04:54:10
Use this to connect to oracle RAC (Real Application Cluster): jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on) (ADDRESS=(PROTOCOL=TCP)(HOST=host1) (PORT=1521)) (ADDRESS=(PROTOCOL=TCP)(HOST=host2) (PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=service) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = BASIC) (RETRIES = 180) (DELAY = 5)) )) From Oracle Database JDBC Developer's Guide : Specifier Supported Drivers Example Oracle Net connection descriptor Thin, OCI Thin, using an address list: url="jdbc:oracle:thin:@(DESCRIPTION= (LOAD_BALANCE=on) (ADDRESS_LIST= (ADDRESS=(PROTOCOL=TCP)(HOST=host1) (PORT=1521)) (ADDRESS=(PROTOCOL=TCP)(HOST=host2)(PORT=1521))) (CONNECT_DATA=(SERVICE_NAME=service_name)))" OCI, using a cluster: "jdbc:oracle:oci:@(DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=cluster_alias) (PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=service_name)))" Thin-style service name Thin "jdbc:oracle:thin:scott/tiger@//myhost:1521/myservicename" LDAP syntax Thin "jdbc:oracle:thin:@ldap://ldap.example.com:7777/sales,cn=OracleContext,dc=com" Bequeath connection OCI Empty. That is, nothing after @ "jdbc:oracle:oci:scott/tiger/@" TNSNames alias Thin, OCI OracleDataSource ods = new OracleDataSource(); ods.setTNSEntryName("MyTNSAlias");
Previous  1 2 3 4 5 6 7 8 9 10 Next