aspose file tools*
The moose likes Servlets and the fly likes Why dont we have a request.setParameter() ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Why dont we have a request.setParameter() ?" Watch "Why dont we have a request.setParameter() ?" New topic
Author

Why dont we have a request.setParameter() ?

Celinio Fernandes
Ranch Hand

Joined: Jun 28, 2003
Posts: 547

I do not know if it is a smart question but I am curious to know.
I am checking the various scope and attributes/parameters associated and i am a bit surprised to see that the request scope has a java.lang.String getParameter(java.lang.String name) method but no setParameter method.

Why ?


SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCBCD 5
Visit my blog
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60985
    
  65

Request parameters are submitted to a servlet or JSP from a client via HTTP. They are not set by server-side code so there is no need for any set methods.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shankar sanjay
Ranch Hand

Joined: Sep 14, 2009
Posts: 117
Hi,

I want to redirect (out of our website) to some other site with adding some parameters as input. How can i solve this?

can you please help me on this?
Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179
Shankar sanjay wrote:Hi,

I want to redirect (out of our website) to some other site with adding some parameters as input. How can i solve this?

can you please help me on this?


you can append those data with the url. But that is not advisable if the data is too bulky. Instead you can post your data . But the other page ( the url where you are redirecting), must know how to fetch the data you are sending


Programming is about thinking, NOT coding
Shankar sanjay
Ranch Hand

Joined: Sep 14, 2009
Posts: 117
thanks for the reply, the problem is the data is like 2mb size characters(textarea) and other site is expecting in POST method and i think they are using request.paramter("textarea") something like, otherwise i could have used request.setAttribute(). is there any better way to handle this?
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Shankar,

If you want to use redirect to transfer to another page and at the same time if you want to transfer the data then the option is
session only.

you can set it and once you get the data you can remove it from the session .
Please correct me if i am wrong as with redirect request object will not be available.

Regards
Jatan

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41488
    
  52
Snce we're talking about redirecting to another server, no session is available. Nor is a POST possible.


Ping & DNS - my free Android networking tools app
Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179
I think sending the data through web services is a better option .
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi ,

I think i misunderstood the question.

Correct me if i am wrong

we can use httpclient in this scenario to redirect to another server.I am interested to know which is good httpclient or java.net ?

Regard
jatan



Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41488
    
  52
HttpClient can help to access another web site, not to redirect a request.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why dont we have a request.setParameter() ?