GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Geting error while i accessing URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Geting error while i accessing URL" Watch "Geting error while i accessing URL" New topic
Author

Geting error while i accessing URL

bhaskaritp naidu
Ranch Hand

Joined: May 21, 2007
Posts: 45
Hi!

I am new to this scwcd , i completed chapter1 in hfsj book.

I created all the files in my , according to book exercise (displaying DATE).

After deploying , while i am giving URL , in serverside , it is displaying error as bad packet signature following lines of 00 symbols . and finally nullpointerexception excuting org.apache.jk.common.socketexception


Please help me

Thnaks in advance..

bhaskar
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

be clear about web.xml and getting form values on servlet

can you post your code?
[ October 18, 2008: Message edited by: seetharaman venkatasamy ]
bhaskaritp naidu
Ranch Hand

Joined: May 21, 2007
Posts: 45
Hi !

This is my servlet code

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class Ch1Servlet extends HttpServlet{

public void doGet(HttpServletRequest request , HttpServletResponse response)throws ServletException,IOException {

PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();

out.println("<html>"+"<body>"+today +"</body>"+"</html>");


}
}

this is my web.xml code



<?xml version="1.0" encoding="UTF-8"?>
<!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>


<servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>


<servlet-mapping>
<servlet-name>Chapter1 Servlet</servlet-name>
<url-pattern>/Serv1</url-pattern>
</servlet-mapping>


</web-app>



i created folder name in web app as ch1

i followed all directory sturctute , how they mentioned in that book


URL:http://localhost:8009/ch1/Serv1


Thanks and Regards
Bhaskar
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

<servlet-class>Ch1Servlet</servlet-class>

1.the class name should be fully qualified name(with package).

example com.Ch1Servlet


2.<servlet-name>Chapter1 Servlet</servlet-name>

why you need space between name (it is discouraged)
[ October 18, 2008: Message edited by: seetharaman venkatasamy ]
bhaskaritp naidu
Ranch Hand

Joined: May 21, 2007
Posts: 45
Hi !

it does not have any package structure.

it is first example in hfsj book in first chapter.

Thanks in advance!!!


Regards
bhaskar
bhaskaritp naidu
Ranch Hand

Joined: May 21, 2007
Posts: 45
Please give me response.i am loosing my confidence

Thanks and regards
Bhaskar
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42023
    
  64
It would be very unusual for the web app to run on port 8009; normally it's port 8080, while port 8009 serves as Apache JK connector port. Did you change the server.xml file to make it so? If not, try port 8080 instead.


Ping & DNS - my free Android networking tools app
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by bhaskaritp naidu:
this is my web.xml code



<?xml version="1.0" encoding="UTF-8"?>
<!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>


<servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>


<servlet-mapping>
<servlet-name>Chapter1 Servlet</servlet-name>
<url-pattern>/Serv1</url-pattern>
</servlet-mapping>


</web-app>






Oops! where is your </servlet> tag
[ October 20, 2008: Message edited by: seetharaman venkatasamy ]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Also, you should be using a web.xml which looks like this one (How do I declare the web.xml file for Servlets 2.4 and JSP 2.0?).
[ October 20, 2008: Message edited by: Christophe Verre ]

[My Blog]
All roads lead to JavaRanch
bhaskaritp naidu
Ranch Hand

Joined: May 21, 2007
Posts: 45
Hi All!

sorry , still it is showing same exception and sequence of zero's.

i changed web.xml properly.

but still it is raising same problem.

please help me out , to come out from my first problem.

thanks in advance

regards
bhaskar
bhaskaritp naidu
Ranch Hand

Joined: May 21, 2007
Posts: 45
Hi !

-fyi-

i added servlet end tag </servlet> in my web.xml as per seetharaman comments.

regards
bahskar
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42023
    
  64
So Tomcat is REALLY set up to serve web content on port 8009? Have you checked the server.xml file to make sure it is?
bhaskaritp naidu
Ranch Hand

Joined: May 21, 2007
Posts: 45
Hi !

i am new to TOMCAT as well

here i am copying my server.xml file.


<?xml version='1.0' encoding='utf-8'?>
<Server>
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/>
<Resource auth="Container" description="Web Self Care registration database on Local DB2" name="jdbc/wsc_reg_db" type="javax.sql.DataSource"/>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
<ResourceParams name="jdbc/wsc_reg_db">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>60</value>
</parameter>
<parameter>
<name>logAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>30</value>
</parameter>
<parameter>
<name>password</name>
<value>webuser1</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://10.25.101.49:3306/wsc_twc(cvgdev1e8x)</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>username</name>
<value>webuser</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<Service name="Catalina">
<Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="8080" redirectPort="8443">
</Connector>
<Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443">
</Connector>
<Engine defaultHost="localhost" name="Catalina">
<Host appBase="webapps" name="localhost">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>
</Host>
<Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
</Engine>
</Service>
</Server>


thanks and regards
bhaskar
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42023
    
  64
So it's exactly as I said in my post yesterday: Tomcat is NOT set up to receive HTTP requests on port 8009 - it expects them on port 8080, like all Tomcat installations do by default.

Use "8080" instead of "8009" in your URL, and it will probably work.
bhaskaritp naidu
Ranch Hand

Joined: May 21, 2007
Posts: 45
Hi !

i used 8080 instead of 8009 , now it is showing HTTP status 404 "resource not available page


Thanks and Regards
Bhaskar
ashok ballu
Ranch Hand

Joined: Sep 17, 2007
Posts: 30
Check once again Your application directory structure.

Application
-> WEB-INF
----->classes
---------->.class

and URL : http://localhost:8080/application/(URL-PATTERN)

definitely it will execute, check once...........
[ October 22, 2008: Message edited by: ashok ballu ]

ASHOK BALLU SCJP1.5 SCWCD1.5
bhaskaritp naidu
Ranch Hand

Joined: May 21, 2007
Posts: 45
Hi !


Thank you all!!!
Thanks a lot for all your help..

i succeeded with my first program execution successfully with all your help

all your help boost up my confidence level

Thanks and Regards
bhaskar
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by bhaskaritp naidu:

i succeeded with my first program execution successfully with all your help

all your help boost up my confidence level





 
GeeCON Prague 2014
 
subject: Geting error while i accessing URL