• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Geting error while i accessing URL

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please give me response.i am loosing my confidence

Thanks and regards
Bhaskar
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
bhaskaritp naidu
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

-fyi-

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

regards
bahskar
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi !

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


Thanks and Regards
Bhaskar
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
bhaskaritp naidu
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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





 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic