Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

First Java EE web app (Eclipse - Tomcat )

preferences-- server-- run time envmnts (need to copy and extract tomcat 7) tomcat 7--> next

https://tomcat.apache.org/download-70.cgi(to before download )

jdk 1.7 with tomcat 7 worked
jdk1.5.0_22  with jboss-4.0.3SP1 best

---------------------------------------
First Web App



















Normally we dont show jsp pages directly. all should handle through java file.

index.jsp file
<body>
<form action="serverletex" method="post">
<table border="0">
<tr>
<td>First Name : </td> <td> <input type="text" name="firstname" /> </td>
</tr>
<tr>
<td>Last Name: </td> <td> <input type="text" name="lastname" /> </td>
</tr>
<tr>
<td colspan="2"> <input type="submit" value="Submit" /> </td>
</tr>
</table>
</form>
</body>
----------------------------------
output.jsp file
<body>
    <h1>Your name is </h1>
    <% 
    String fname=(String) request.getAttribute("fname");
    String lname=(String) request.getAttribute("lname");
    out.print(fname+" "+lname);    
     %>
</body>
----------------------------------
ServerletEx.java file (serverlet)
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       
        if(request.getParameter("firstname") == null ||request.getParameter("firstname") == null){
            getServletContext().getRequestDispatcher("/index.jsp").forward(request, response);
            return;
        }
       
        //PrintWriter out = response.getWriter();
        String fname=request.getParameter("firstname");
        String lname=request.getParameter("lastname");
        //out.println("Hello " +fname+ " " + lname);
       
        request.setAttribute("fname", fname);
        request.setAttribute("lname", lname);
       
        getServletContext().getRequestDispatcher("/output.jsp").forward(request, response);      
       
            }

-----------------------------------------



 --------------------------------
download tomcat 7 for windows
copy apache tomcat folder to  c:/
check java is installed.
set path(java) variable in environment variables(in system properties)
in environment variables, a system variable should be added >JAVA_HOME --->C:\Program Files\Java\jdk1.7.0_79\
then go cmd
cd ->apache bin folder >startup.bat (shoutdown.bat)
 before that copy "exported" war file to webapp folder in tomcat folder
----------------------------------
same things in linux
-------------------

more that 1 instances

in ~/.bashrc
export CATALINA_HOME=/opt/apache-tomcat-7.0.67

---------------------
[root@hasaranga apache-tomcat-7.0.67]# cp -rf conf /opt/tomcat1/
[root@hasaranga apache-tomcat-7.0.67]# cp -rf logs /opt/tomcat1/
[root@hasaranga apache-tomcat-7.0.67]# cp -rf temp/ /opt/tomcat1/
[root@hasaranga apache-tomcat-7.0.67]# cp -rf webapps /opt/tomcat1/
[root@hasaranga apache-tomcat-7.0.67]# cp -rf work /opt/tomcat1/

cp -rf tomcat1 tomcat2

vi tomcat1/conf/server.xml
server port 8'1'05
Connector port=8'1'8'1'
-- Define an AJP 1.3 Connector on port 8009 -->Connector port=8'1'09

vi startuptomcat1.sh
export CATALINA_BASE=/opt/tomcat1
cd $CATALINA_HOME/bin
./startup.sh

vi shutdownptomcat1.sh
export CATALINA_BASE=/opt/tomcat1
cd $CATALINA_HOME/bin
./shutdown.sh
(do other scripts as this)
--
can access port 8181,8282,8383
------------------------------------------------

------------------------------------------------
in ~/.bashrc
export CATALINA_HOME=/opt/apache-tomcat-7.0.67

---------------------
[root@hasaranga apache-tomcat-7.0.67]# cp -rf conf /opt/tomcat1/
[root@hasaranga apache-tomcat-7.0.67]# cp -rf logs /opt/tomcat1/
[root@hasaranga apache-tomcat-7.0.67]# cp -rf temp/ /opt/tomcat1/
[root@hasaranga apache-tomcat-7.0.67]# cp -rf webapps /opt/tomcat1/
[root@hasaranga apache-tomcat-7.0.67]# cp -rf work /opt/tomcat1/

cp -rf tomcat1 tomcat2

vi tomcat1/conf/server.xml
server port 8'1'05
Connector port=8'1'8'1'
-- Define an AJP 1.3 Connector on port 8009 -->Connector port=8'1'09

vi startuptomcat1.sh
export CATALINA_BASE=/opt/tomcat1
cd $CATALINA_HOME/bin
./startup.sh

vi shutdownptomcat1.sh
export CATALINA_BASE=/opt/tomcat1
cd $CATALINA_HOME/bin
./shutdown.sh
(do other scripts as this)
=================================================
install apache, httpd downoad search
downlod, extract
./configure --prefix=/usr/local/apache --enable-rewrite=shared --enable-proxy=shared (/usr/sbin/apxs)
sudo make
sudo make install
---
mod_jk connector download
cd native
./configure --with-apxs=/usr/local/apache/bin/apxs
make
make install
 -----------------
vi /usr/local/apache/conf/workers.properties
worker.tomcat1(any name).type=ajp13
worker.tomcat1.host=localhost
worker.tomcat1.port(ajp port)=8109
---
worker.list=tomcat1,tomcat2,tomcat3

worker.tomcat1.type=ajp13
worker.tomcat1.host=localhost
worker.tomcat1.port=8109

worker.tomcat2.type=ajp13
worker.tomcat2.host=localhost
worker.tomcat2.port=8309

worker.tomcat3.type=ajp13
worker.tomcat3.host=localhost
worker.tomcat3.port=8209

----------------
httpd.conf
LoadModule    jk_module  modules/mod_jk.so

JkWorkersFile conf/workers.properties

JkLogFile     logs/mod_jk.log
JkLogLevel    emerg
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkOptions     +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat     "%w %V %T"
JkMount /serversa* balancer
JkMount /status stat
Worers.roperties
worker.list=balancer,stat

worker.tomcat1.type=ajp13
worker.tomcat1.host=localhost
worker.tomcat1.port=8109
worker.tomcat1.lbfactor=10

worker.tomcat2.type=ajp13
worker.tomcat2.host=localhost
worker.tomcat2.port=8209
worker.tomcat2.lbfactor=10

worker.tomcat3.type=ajp13
worker.tomcat3.host=localhost
worker.tomcat3.port=8309
worker.tomcat3.lbfactor=10

worker.balancer.type=lb
worker.balancer.balance_workers=tomcat1,tomcat2,tomcat3

worker.stat.type=status

No comments:

Post a Comment