• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF 2.0 , passing URL hidden parameters in ExternalContext.redirect() programmatically

 
Divya Sudarsan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , I have the following code on the submit of command button on the jsp page



I need to send all the parameters after rwservlet? as hidden parameters. These values do not come from any form field on the page. They are a part of the properties file on the disk. I would not like them to be displayed to the user when loading the next webpage or on the next web page.

Please let me know if there is any way to mark specific parameters in externalcontext.redirect() as hidden programatically

The xhtml code is

 
K. Tsang
Bartender
Posts: 3521
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mention the parameters are in a properties file on disk... then why not just populate a Properties from the start and put it in a session or application scope. Then use that object instead in the redirected page or whenever you need it.
 
Divya Sudarsan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. Can you please help me with samples which can make me understand in detail ?

Also my bad, only some of the properties are on disk. for e.g DB name. The others will be populated dynamically based on some business logic on the code.
 
K. Tsang
Bartender
Posts: 3521
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Divya Sudarsan wrote:Also my bad, only some of the properties are on disk. for e.g DB name. The others will be populated dynamically based on some business logic on the code.


In that case I suggest you store these so-called properties in a DB table and fetch them when necessary.

As for examples: if you know how to "load" up a Properties, you should be fine. If in doubt check out the java.util.Properties API.
 
Prabu Pidaran
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try loading the properties file
Properties urProperties = new Properties().load(new FileInputStream(System.getProperty("YOUR PROPERTY FILE PATH");

Then try to get the values

String dbName = (String) urProperties.get("urKeyValue");

 
Tim Holloway
Saloon Keeper
Posts: 18300
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi , I have the following code on the submit of command button on the jsp page ...


I don't think so. In Java 2.0, JSP view templates are no longer supported. It would have to be an xhtml View Definition Language Template.

I need to send all the parameters after rwservlet? as hidden parameters. These values do not come from any form field on the page.


If you don't have a form, then you are submitting an HTTP GET request. On an HTTP GET the parameters are part of the URL and by definition, not something that can be hidden.

The cleanest/simplest way to hide data is never to post it out to the client to begin with. In JSF, this is a normal part of the architecture. Just keep your data in (session-scope) backing beans.

On the other hand, it appears that you are attempting to forward a parameterized request to an external server, so session-scope data is not an option. And, in fact, it's the report server that forces the request parameters to be part of the URL.

If you can, reformulate your request to submit the parameters in a form. That well keep them off of the URL and thus invisible to the client. If you cannot, you are probably going to have to serve as a proxy. Instead of forwarding the request, your application code will probably have to submit the request internally, receive the generated report output, and pass that output back to the client. Since the output will probably NOT be in JSF format (and will most likely be something like a PDF), your actual Submit handler is probably better done as a Plain Old Servlet, not routed via JSF.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic