It's not a secret anymore!
The moose likes Servlets and the fly likes servlet not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet not working" Watch "servlet not working" New topic

servlet not working

yogitad devarajan

Joined: Oct 18, 2006
Posts: 8
Hi ,
I am trying to insert an image in the table.Here is the jsp for that where I give an image name..Nothing happens once I run it..The browser is blank..The code works fine when I put it in a java class with a main method..Could someone please tell me what the problem is..I am new to java and struggling with this..

Here is the servlet

[ October 23, 2006: Message edited by: Ben Souther ]
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Javaranch tip:

If you are going to post more than a line or two of your code, wrap that
code in a set of UBB Code tags.
Doing so will help to preserve your code's indenting, making it easier to read.
If it is easier to read, more people will actaully read it and you will
stand a better chance of getting help with your question.
See UseCodeTags for more
help with UBB code tags.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Are you sure that your servlet is getting called???

Post your web.xml, if you can.
Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 626

Moreover it seems you are not putting any logging system or System.out.println to debug. Without debugging the app you can never find whats wrong.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

In the servlet, I don't see anything being sent to the client. No output, no redirecting, no forwarding. Maybe I should look again ?

[My Blog]
All roads lead to JavaRanch

Joined: Oct 02, 2006
Posts: 17
In your servlet you can either call getServletOutputStream() or getWriter() method on the response object. You cant call both.
Since your jsp is also a servlet, and getWriter() will be automatically called by the container to provide you out implicit valriable. So you cant call getServletOutputStrem() in JSP. And using your out variable you cant send any binary data. So you cant process images in your JSP
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Welcome to JavaRanch!

We're pleased to have you here with us in the servlets forum, but there
are a few rules that need to be followed, and one is that proper names are
required. Please take a look at the
JavaRanch Naming Policy and
adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here
I agree. Here's the link:
subject: servlet not working
It's not a secret anymore!