You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Ralph A. Borriello" <ra...@comcast.net> on 2004/09/04 07:49:38 UTC

Newbie question about getting first servlet working in tomcat on iseries v5r2

Hello all,  

I work on an as/400 (iseries) version v5r2. I have setup a apache/tomcat server instance under the ibm http server and am trying to get a simple helloservlet servlet to work properly. The server instance is referencing version 1.3 of the jdk. I have compiled the java using jedit and jcompile plugin on windows and copied and pasted the html and class files to the iseries via a mapped drive  

The sample is a html file and a class file. It is a simple form where the servlet just mirrors back the name that was typed on the form. When I enter the name, I get a page cannot be found error. The url is modified to look like this: http://10.126.2.2:8082/HelloServlet?user_name=asdasdf (as I typed asdasdf).

I have included the source for the html, the java program, and the server logs. In them it does say that it cant find the servlet called HelloServlet, but it is there. Do I have to package the files in a .war file ?? I have scoured the documenation that I could find on the iseries and the tomcat sites and have tried many things but cant get it working. Any help would be greatly appreciated. 
Thanks for taking the time to read this :) 

If this is the wrong forum for this type of question or if there is a better one, please let me know. 

All the object authorites give full access to *public and the user that the server is running under. 

The httpd.conf file: 


# Apache Default server configuration
LoadModule jk_module /QSYS.LIB/QHTTPSVR.LIB/QZTCJK.SRVPGM

# General setup directives
HotBackup Off
CgiConvMode %%MIXED/MIXED%%
TimeOut 30000
KeepAlive Off
DocumentRoot /www/apachedft/htdocs
AddLanguage en .en

# Deny most requests for any file
JkWorkersFile /www/apachedft/conf/workers.properties
JkLogFile /www/apachedft/logs/jk.log
JkLogLevel Error
JkMount /calc mytomcat
ServerUserID QTMHHTTP
DirectoryIndex index.html
<Directory />
  order allow,deny
  deny from all
  Options -Indexes -ExecCGI -includes
  AllowOverride Limit Options
</Directory>

# Allow requests for files in document root
<Directory /www/apachedft/htdocs>
  order allow,deny
  allow from all
</Directory>
Listen *:8082
LogLength 10485760
LogLevel Debug
AccessFileName .htaccess






The html file:


<html><body> 
<form method="GET" action="HelloServlet"> 
    Please enter your name: 
    <input type="text" name="user_name"> 
    <input type="submit" value="OK"> 
</form> 
</body></html>






the java program: 

/** 
 * This program is an example from the book "Internet 
 * programming with Java" by Svetlin Nakov. It is freeware. 
 * For more information: http://www.nakov.com/books/inetjava/ 
 */ 
import java.io.*; 
import javax.servlet.*; 
import javax.servlet.http.*; 
 
public class HelloServlet extends HttpServlet { 
    public void doGet (HttpServletRequest aRequest, 
        HttpServletResponse aResponse) 
    throws ServletException, IOException { 
        aResponse.setContentType("text/html"); 
        ServletOutputStream out = aResponse.getOutputStream(); 
        String userName = aRequest.getParameter("user_name"); 
        out.println("<html>"); 
        out.println("<head>"); 
        out.println("\t<title>Hello Servlet</title>"); 
        out.println("</head>"); 
        out.println("<body>"); 
        out.println("\t<h1>Hello, " + userName + "</h1>"); 
        out.println("</body></html>"); 
    } 
}





Portion of the web.xml file: 


    <servlet>              
       <servlet-name>      
          servlet1         
       </servlet-name>     
       <servlet-class>     
          HelloServlet     
       </servlet-class>    
       <load-on-startup>   
          3                
       </load-on-startup>  
       </servlet-name>    
       <servlet-class>    
          HelloServlet    
       </servlet-class>   
       <load-on-startup>  
          3               
       </load-on-startup> 
    </servlet>            
    <servlet-mapping>     
       <servlet-name>     
          servlet1        
       </servlet-name>    
       <url-pattern>      
          /*              
       </url-pattern>     
    <servlet-mapping>  
       <servlet-name>  
          servlet1     
       </servlet-name> 
       <url-pattern>   
          /*           
       </url-pattern>  
    </servlet-mapping> 
 </web-app>            





the error_log messages: 

ZSRV_MSG0018: File /www/apachedft/htdocs/HelloServlet does not exist, refeerer: http://10.126.2.2:8082/helloform.html    
ZSRV_MSG0016: URI in request GET /HelloServlet?user_name=asdasdf HTTP/1.1   is not valid, referer: http://10.126.2.2:8082/helloform.html  



the jvmstdout.txt log: 


Starting up StartupThread                                   
Starting tomcat. Check logs/tomcat.log for error messages   
cannot load servlet name: servlet1: HelloServlet            
Library /QSYS.LIB/QHTTPSVR.LIB/QZTCJK.SRVPGM loaded         
Running ...                                                 
End waiting                                                 
Running fine                                                




Sorry for the length of the email, I could not find any other errors anywhere. 

any help is appreciated. 

thanks

Ralph A. Borriello 

rablxm@comcast.net


RE: [tomcat] Newbie question about getting first servlet working in tomcat on iseries v5r2

Posted by Ernesto Echeverría <er...@telemovil.net>.
To me this sounds like a directory misplacement.

Can you elaborate on:

What directories have you placed your files into?
Are you using the ROOT webapp?
Have you tried the tomcat sample applications? 
If you type the html file name into the url does your app work?

Other tip I could give you now has to do with working the simple
configurations first and then climbing on the complexity ladder.
For example why don't you try your webapp in the tomcat instance directly
and later worrying about configuring mod_jk passthru.

Regards.

José Ernesto Echeverría
ernestoe@telemovil.net

 

-----Original Message-----
From: Ralph A. Borriello [mailto:rablxm@comcast.net] 
Sent: Viernes, 03 de Septiembre de 2004 11:50 p.m.
To: tomcat-user@jakarta.apache.org
Subject: [tomcat] Newbie question about getting first servlet working in
tomcat on iseries v5r2

Hello all,  

I work on an as/400 (iseries) version v5r2. I have setup a apache/tomcat
server instance under the ibm http server and am trying to get a simple
helloservlet servlet to work properly. The server instance is referencing
version 1.3 of the jdk. I have compiled the java using jedit and jcompile
plugin on windows and copied and pasted the html and class files to the
iseries via a mapped drive  

The sample is a html file and a class file. It is a simple form where the
servlet just mirrors back the name that was typed on the form. When I enter
the name, I get a page cannot be found error. The url is modified to look
like this: http://10.126.2.2:8082/HelloServlet?user_name=asdasdf (as I typed
asdasdf).

I have included the source for the html, the java program, and the server
logs. In them it does say that it cant find the servlet called HelloServlet,
but it is there. Do I have to package the files in a .war file ?? I have
scoured the documenation that I could find on the iseries and the tomcat
sites and have tried many things but cant get it working. Any help would be
greatly appreciated. 
Thanks for taking the time to read this :) 

If this is the wrong forum for this type of question or if there is a better
one, please let me know. 

All the object authorites give full access to *public and the user that the
server is running under. 

The httpd.conf file: 


# Apache Default server configuration
LoadModule jk_module /QSYS.LIB/QHTTPSVR.LIB/QZTCJK.SRVPGM

# General setup directives
HotBackup Off
CgiConvMode %%MIXED/MIXED%%
TimeOut 30000
KeepAlive Off
DocumentRoot /www/apachedft/htdocs
AddLanguage en .en

# Deny most requests for any file
JkWorkersFile /www/apachedft/conf/workers.properties
JkLogFile /www/apachedft/logs/jk.log
JkLogLevel Error
JkMount /calc mytomcat
ServerUserID QTMHHTTP
DirectoryIndex index.html
<Directory />
  order allow,deny
  deny from all
  Options -Indexes -ExecCGI -includes
  AllowOverride Limit Options
</Directory>

# Allow requests for files in document root <Directory
/www/apachedft/htdocs>
  order allow,deny
  allow from all
</Directory>
Listen *:8082
LogLength 10485760
LogLevel Debug
AccessFileName .htaccess






The html file:


<html><body>
<form method="GET" action="HelloServlet"> 
    Please enter your name: 
    <input type="text" name="user_name"> 
    <input type="submit" value="OK">
</form>
</body></html>






the java program: 

/**
 * This program is an example from the book "Internet
 * programming with Java" by Svetlin Nakov. It is freeware. 
 * For more information: http://www.nakov.com/books/inetjava/
 */
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*; 
 
public class HelloServlet extends HttpServlet { 
    public void doGet (HttpServletRequest aRequest, 
        HttpServletResponse aResponse) 
    throws ServletException, IOException { 
        aResponse.setContentType("text/html"); 
        ServletOutputStream out = aResponse.getOutputStream(); 
        String userName = aRequest.getParameter("user_name"); 
        out.println("<html>"); 
        out.println("<head>"); 
        out.println("\t<title>Hello Servlet</title>"); 
        out.println("</head>"); 
        out.println("<body>"); 
        out.println("\t<h1>Hello, " + userName + "</h1>"); 
        out.println("</body></html>"); 
    }
}





Portion of the web.xml file: 


    <servlet>              
       <servlet-name>      
          servlet1         
       </servlet-name>     
       <servlet-class>     
          HelloServlet     
       </servlet-class>    
       <load-on-startup>   
          3                
       </load-on-startup>  
       </servlet-name>    
       <servlet-class>    
          HelloServlet    
       </servlet-class>   
       <load-on-startup>  
          3               
       </load-on-startup> 
    </servlet>            
    <servlet-mapping>     
       <servlet-name>     
          servlet1        
       </servlet-name>    
       <url-pattern>      
          /*              
       </url-pattern>     
    <servlet-mapping>  
       <servlet-name>  
          servlet1     
       </servlet-name> 
       <url-pattern>   
          /*           
       </url-pattern>  
    </servlet-mapping> 
 </web-app>            





the error_log messages: 

ZSRV_MSG0018: File /www/apachedft/htdocs/HelloServlet does not exist,
refeerer: http://10.126.2.2:8082/helloform.html    
ZSRV_MSG0016: URI in request GET /HelloServlet?user_name=asdasdf HTTP/1.1
is not valid, referer: http://10.126.2.2:8082/helloform.html  



the jvmstdout.txt log: 


Starting up StartupThread                                   
Starting tomcat. Check logs/tomcat.log for error messages   
cannot load servlet name: servlet1: HelloServlet            
Library /QSYS.LIB/QHTTPSVR.LIB/QZTCJK.SRVPGM loaded         
Running ...                                                 
End waiting                                                 
Running fine                                                




Sorry for the length of the email, I could not find any other errors
anywhere. 

any help is appreciated. 

thanks

Ralph A. Borriello 

rablxm@comcast.net



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org