aspose file tools*
The moose likes Servlets and the fly likes How to call a list of URLs from a single servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to call a list of URLs from a single servlet" Watch "How to call a list of URLs from a single servlet" New topic
Author

How to call a list of URLs from a single servlet

avneesh atri
Greenhorn

Joined: Jul 18, 2011
Posts: 20
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

Joined: Mar 22, 2000
Posts: 12835
    
    5
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

Joined: Jul 18, 2011
Posts: 20
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

Joined: Oct 21, 2008
Posts: 1107

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

Joined: Aug 30, 2010
Posts: 147

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.


OCPJP
In preparing for battle I have always found that plans are useless, but planning is indispensable. -- Dwight D. Eisenhower
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to call a list of URLs from a single servlet