• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

invalid servlet downloads

 
asit dhal
Greenhorn
Posts: 13
C++ Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an HTML page , register.html. It calls a servelet 'Register.java'

The problem is that, the servlet displays a form window for user input. When user inputs data and submits, then a new window appears which asks us to download Register.class file.

Please suggest me how to fix this ??

Here is the code..

 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two questions:
1. Under what environment are you executing this servlet?
2. Why are you extending GenericServlet, given that you appear to be writing a HTTP application?
You should be extending HttpServlet so you can use doGet, doPost, etc instead of service.

Bill
 
asit dhal
Greenhorn
Posts: 13
C++ Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its Glass Fish Opensource server(embedded in Net Beans 7).

Actually I am using this for the first time. So, whatever in the book, I am just following.

Can you suggest me what is the reason of that download comes ??
 
asit dhal
Greenhorn
Posts: 13
C++ Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
finally a day long R & D in google and so many hit and trial found the actual error...a silly spelling mistake....


should be
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
asit dhal wrote:Its Glass Fish Opensource server(embedded in Net Beans 7).

Actually I am using this for the first time. So, whatever in the book, I am just following.


If the book is advising you to extend GenericServlet and override service method you have gotten a bad book.

Bill
 
Daniel Doboseru
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To better understand what Bill told you, you should know that the service method which you overriden, is used to handle the requests done to the Servlets. For a Generic Servlet, is ok to override it, but better than that, you should use an HttpServlet, and instead of overriding the service method, you just simply need to override the doGet()/doPost() methods. Besides that, there are many advantages when using a HttpServlet instead of a GenericServlet in a web-environment, so you might re-analyze your problem. Good day!
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic