Install MySQL

Java No Comments »

Install MySQL Database version 3.23.54

#To set the root password use the following commanding changing my_password to the password you want for the root user to access MySQL.
cat /etc/my.cnf
mysqladmin -u root password "newpwd"
mysqladmin -u root -p create linksdb
mysql linksdb

shell> mysql -u root
mysql> DELETE FROM mysql.user WHERE User = '';
mysql> FLUSH PRIVILEGES;

Install Tomcat server

Java No Comments »

Installation of Java 2 SDK and Jakarta Tomcat Server

cd /usr/local/src
chmod +x j2sdk-1_4_2_08-linux-i586-rpm
rpm -i j2sdk-1_4_2_08-linux-i586.rpm

# Add these lines to /etc/profile
echo JAVA_HOME=/usr/java/j2sdk1.4.2_08 >>/etc/profile
echo export JAVA_HOME >>/etc/profile

unzip jakarta-tomcat-5.0.28.zip
mv jakarta-tomcat-5.0.28 /usr/java
groupadd tomcat
useradd -g tomcat tomcat
cd /usr/java
ln -s jakarta-tomcat-5.0.28 jakarta-tomcat
chown tomcat.tomcat /usr/java/jakarta-tomcat
chown -R tomcat.tomcat /usr/java/jakarta-tomcat-5.0.28
cd jakarta-tomcat/bin
chmod +x *.sh
. startup.sh
. shutdown.sh
# Setting up ntsysv configuration for tomcat
cat >/etc/rc.d/init.d/tomcat

 …
 …
 …
EOF
chmod +x /etc/rc.d/init.d/tomcat
chkconfig –add tomcat
service tomcat start
service tomcat status
# Modify tomcat group at /etc/group
cd /home/tomcat
chmod g+w /home/tomcat

Standard JSP tags

Java No Comments »

The standard JSP tags are:

  • <jsp:useBean> - Allows you to put or look up a bean in the page, request, session, or application scope. (This tag is very useful for maintaining state). JavaBean instances: Recall that the JSP engine only loads a new instance of the bean if it can’t find an existing instance in scope. This means you can use a bean as a storage container that keeps track of the application’s data anywhere within its scope.
  • <jsp:setProperty> - Allows you to set the property of a bean that is already defined and in scope. Use the <jsp:setProperty> tag for Bean initialization.
  • <jsp:getProperty> - Takes the value of a bean’s property, converts it to a string, and places it in the output stream.
  • <jsp:param> – Provides parameters and values to the include, forward, and plugin standard actions.
  • <jsp:include> – Includes a page at request time instead of translation time with the @include directive.
  • <jsp:forward> – Forwards the request to another resource in the existing Web application.
  • <jsp:plugin> – Enables the JSP author to generate HTML using client-browser independent constructs that result in the download and subsequent execution of the specified applet or component (results of the evaluated tag are typically replaced by an <object> or <embed> tag).

jsp page implicit variables

Java No Comments »

There are certain implicit variables available to a JSP:

  • request – reference to the HttpServletRequest
  • response – reference to the HttpServletResponse
  • pageContext – provides access to the namespaces within the JSP
  • session – reference to the HttpSession
  • application – reference to the ServletContext
  • config – reference to the ServletConfig
  • page – reference to the current instance of the JSP being accessed; analogous to using this in the generated Servlet for this JSP
  • exception – reference to the uncaught exception thrown by a JSP; only available on JSPs with the isErrorPage set to true

java String

Java No Comments »

The String class represents character strings. All string literals in Java
programs, such as “abc”, are implemented as instances of this class. Strings are
constant; their values cannot be changed after they are created. String buffers
support mutable strings. Because String objects are immutable they can be
shared.

For example:

     String str = "abc";

 is equivalent to:

     char data[] = {'a', 'b', 'c'};
     String str = new String(data);

 Here are some more examples of how strings can be used:

     System.out.println("abc");
     String cde = "cde";
     System.out.println("abc" + cde);
     String c = "abc".substring(2,3);
     String d = cde.substring(1, 2);

Jsp

Programming, Java No Comments »

A JSP oldalak (Java Server Pages) kiterjesztései a java servleteknek amelyek általános kiterjesztései a Java alapon működő webkiszolgáló számítógépeknek. A Java servletek webes környezetben tulajdonképpen a hagyományos CGI technológiát helyettesítik. A
servlet egy webszerver kérelemre dinamikusan betöltődő modul, amely szerver
oldalon, teljesen a Java Virtuális gép belsejében fut le.

Startup script for Tomcat Servlet Engine

shell scripts, Java No Comments »

Example shell script usage:

  • /etc/rc.d/tomcat start
  • /etc/rc.d/tomcat stop
  • /etc/rc.d/tomcat restart


#!/bin/sh
#
# Startup script for Tomcat, the Apache Servlet Engine
#
# chkconfig: 345 80 20
# description: Tomcat is the Apache Servlet Engine
# processname: tomcat
# pidfile: /var/run/tomcat.pid
#
# Mike Millson <mmillson@meritonlinesystems.com>
#
# version 1.02 - Clear work directory on shutdown per John Turner suggestion.
# version 1.01 - Cross between RedHat Tomcat RPM and Chris Bush scripts
# Tomcat name :)
TOMCAT_PROG=tomcat
# if TOMCAT_USER is not set, use tomcat like Apache HTTP server
if [ -z “$TOMCAT_USER” ]; then
 TOMCAT_USER=”tomcat”
fi
RETVAL=0
# start and stop functions
start() {
    echo -n “Starting tomcat: ”
    chown -R $TOMCAT_USER:$TOMCAT_USER /usr/java/jakarta-tomcat/*
    chown -R $TOMCAT_USER:$TOMCAT_USER /home/tomcat/*
    su -l $TOMCAT_USER -c ‘/usr/java/jakarta-tomcat/bin/startup.sh’
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/subsys/tomcat
    return $RETVAL
}
stop() {
    echo -n "Stopping tomcat: "
    su -l $TOMCAT_USER -c '/usr/java/jakarta-tomcat/bin/shutdown.sh'
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/subsys/tomcat /var/run/tomcat.pid
}
#    rm -rf /usr/java/jakarta-tomcat/work/*

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        stop
        # Ugly hack
        # We should really make sure tomcat
        # is stopped before leaving stop
        sleep 2
        start
        ;;
  *)
        echo "Usage: $0 start|stop|restart"
        exit 1
esac
exit $RETVAL

WebSite Powered by webHauser
Entries RSS Comments RSS Login