Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Servlets and the fly likes Making my own servlet (for the first time...) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Making my own servlet (for the first time...)" Watch "Making my own servlet (for the first time...)" New topic
Author

Making my own servlet (for the first time...)

Ori Weisler
Greenhorn

Joined: Feb 26, 2009
Posts: 10
Dear friends,

I trying to get into the world of J2EE, building my own Servlet, and it seems not so smooth and easy... I need help.

I working with the Intellij environment , I open New Project -> web service->Apache Axis. Everything was great. But then, I added
my own MyServlet extends HttpServlet , put a breakpoing in "my init()" and "my doGet()" and was expecting, execute the server (apache)
and expected to see the program stop on my breakpoint, but nope.

Can somebody help me? I guess the problem is the definition in web.xml, but I dont know how to change it.
Here is my current xml:


<display-name>Apache-Axis</display-name>
<servlet>
<display-name>Apache-Axis Servlet</display-name>
<servlet-name>AxisServlet</servlet-name>
<servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
</servlet>
<servlet>
<display-name>Axis Admin Servlet</display-name>
<servlet-name>AdminServlet</servlet-name>
<servlet-class>org.apache.axis.transport.http.AdminServlet</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet>
<display-name>SOAPMonitorService</display-name>
<servlet-name>SOAPMonitorService</servlet-name>
<servlet-class>org.apache.axis.monitor.SOAPMonitorService</servlet-class>
<init-param>
<param-name>SOAPMonitorPort</param-name>
<param-value>5101</param-value>
</init-param>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SOAPMonitorService</servlet-name>
<url-pattern>/SOAPMonitor</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AdminServlet</servlet-name>
<url-pattern>/servlet/AdminServlet</url-pattern>
</servlet-mapping>
<mime-mapping>
<extension>wsdl</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
</web-app>


what should I do?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Change? No, the problem is that you don't have a definition in that web.xml file for your MyServlet class. You have to put one in there. Hint: it should look like the other ones which are already there.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Web service?

Why did you choose a web service project in IntelliJ?

Web services are not web applications. I think this is a mis-step on your part.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ori Weisler
Greenhorn

Joined: Feb 26, 2009
Posts: 10
Hey guys!!

Thanks you for the fast reply!!!

1. I changed the web.xml adding those lines:
<servlet>
<display-name>MyServelet</display-name>
<servlet-name>MyServelet</servlet-name>
<servlet-class>example.MyServlet</servlet-class>
</servlet>

still doesnt work (should I write down the all path? where should the servlet class should be?)

2. I tried to google some info, and its was written that in order to open J2EE project, this is the right way.
What do you recommend?
Ori Weisler
Greenhorn

Joined: Feb 26, 2009
Posts: 10
also when I open web application it asks for choosing web service
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Hi Ori,
Read again what bear has suggested. WebService != Web Application.

I working with the Intellij environment , I open New Project -> web service->Apache Axis.

I use MyEclipse and it has something like this New Project -> Web Project to create Web Project and not Web Service.

Do you see similar kind of option in Intellij IDE? Then we can come to other problem related to Servlet.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

Start over. Really.

You do not need all that web services crap clogging things up and getting in the way. It's just going to make things that much harder to get going.

My recommendation is to grab a copy of the Servlet Specification and read it from cover to cover before proceeding any further. It's a surprisingly easy read and will let you know what's what with regards to servlets.
Ori Weisler
Greenhorn

Joined: Feb 26, 2009
Posts: 10
Tnx guys.

I made it, at last.

I dont understand one thing, why dont keep things simple?

I've just learn learn the ASP.NET with great videos made by microsoft, they keep things simple, and explain
step by step, in a video/pdf.

Why there is nothing like that for Java/J2ee???

Tnx anyway.
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Material? There is tons of material out on internet. Google it.
Video? I have seen couple on www.youtube.com for Java. I am sure you will get some for J2EE(now Java EE) too.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

You made it complicated for yourself by choosing the wrong option and polluting your project with all that web services stuff.

It actually is rather simple. Did you read the Servlet Spec like I advised? If not, you really have no cause for complaint.

And yeah, there are tons and tons of Java material out there.
Ori Weisler
Greenhorn

Joined: Feb 26, 2009
Posts: 10
tnx again!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Making my own servlet (for the first time...)
 
Similar Threads
How do i correct this error
Mistakenly changed web.xml
The AXIS engine could not find a target service to invoke
How to make an Axis web service start/deploy/work automatically
Bridge between REST & WS