• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call a list of URLs from a single servlet

 
avneesh atri
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a list of urls which i want to call from my servlet , each url returns a query string parameter which is required in next url and after calling last url ,i need to perform some logical operations using query string of last url. Is there any way i can call these urls one by one and use the query string parameter of one url in next using a single servlet.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sort of long and possibly time consuming task is not the sort of thing you want to do in a servlet.

However, if you insist, my advice is to get it running in a non-servlet class executed from the command line - after you have handled all the various error condition etc. and have reliable working code - THEN make use of that class in a servlet.

The reason being that trying to work inside the servlet environment just adds extra layers of complexity and slows down the development cycle.

Bill
 
avneesh atri
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:This sort of long and possibly time consuming task is not the sort of thing you want to do in a servlet.

However, if you insist, my advice is to get it running in a non-servlet class executed from the command line - after you have handled all the various error condition etc. and have reliable working code - THEN make use of that class in a servlet.

The reason being that trying to work inside the servlet environment just adds extra layers of complexity and slows down the development cycle.

Bill



it is a good advice , but how to do this programaticaly in a single class.
 
Wendy Gibbons
Bartender
Posts: 1110
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
avneesh atri wrote:
William Brogden wrote:This sort of long and possibly time consuming task is not the sort of thing you want to do in a servlet.

However, if you insist, my advice is to get it running in a non-servlet class executed from the command line - after you have handled all the various error condition etc. and have reliable working code - THEN make use of that class in a servlet.

The reason being that trying to work inside the servlet environment just adds extra layers of complexity and slows down the development cycle.

Bill



it is a good advice , but how to do this programaticaly in a single class.

a servlet is just a chunk of java code, if it is written well, the servlet will extract the parameters from the Get or Post and then call a plain old java method passing the parameters.

you just call the java methods the servlet would call using the return method from the previous method.

Then when you have all these method calls working, you can create the servlets and web pages around them.
 
Pete Nelson
Ranch Hand
Posts: 147
Debian Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
avneesh atri wrote:it is a good advice , but how to do this programaticaly in a single class.


That's a very strange goal for an object-oriented programming language - in most cases, you want to write multiple classes with each class being responsible for only what it absolutely needs to.

That being said, if you're looking to write a java program that needs to make HTTP requests, I would recommend looking at the Apache HTTP Client as a starting point.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic