Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Inserting post data in a context.redirect

 
James Templer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The application I'm developing has a requirement for the user to click
on a button and a file is uploaded to a remote server. Furthermore,
the user is not to be aware of the location of the file on the client
machine. And on top of that the file to be uploaded can be one of
several files uploaded, depending on what the user is doing at the time.

From the JSP page, I submit with an action that calls a function that
has the following in it:

ExternalContext context =
FacesContext.getCurrentInstance().getExternalContext();

context.redirect( "http://validator.w3.org/check?" );

I've tried several ways of putting post data in the header to no
avail. I think I read that when you do a redirect it makes a new
header and all your old header stuff is lost anyway. Is this right?

Also, HttpClient looks like it might be promising, but I think that it
might be a bit of an overkill. Has anyone in this forum had any
experience with this?

James
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Templer:
The application I'm developing has a requirement for the user to click
on a button and a file is uploaded to a remote server. Furthermore,
the user is not to be aware of the location of the file on the client
machine. And on top of that the file to be uploaded can be one of
several files uploaded, depending on what the user is doing at the time.



Sounds fishy. How are you getting the location of a file to be uploaded without the user specifying which file to upload? Your problem will stem from the fact that the input type=file tag will throw some handy dandy stuff in the header so that HTTP knows what to do. Doing that from JSF will be difficult if not impossible to a point.

Is there a reason why you can just step completely out of JSF for this task? Or could you clarify your requirements a bit more and maybe we can find a different/better solution?

Thanks.
 
James Templer
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your help.

The application is for a disabled student resource center (dSRC) at a community college. This is totally being done on a volunteer basis. Anyway, they have form letters that go out by the thousands and I'm trying to automate the process. I know that they'll need to change the form e-mail template from time to time. The law and school policy change what has to be on these forms every few years. The idea is that they click on a button to edit the form template and have three options at this point: save the template to be used in the email mail merge, send a one-up dummy test email, and validate the template's HTML. There are enough people around that know the basics of HTML but knowing that you even can validate it is beyond them. A new law in our state requires that all electronic media be accessible and the first step to being accessible for a web page is to validate properly. They could be editing one of several templates and that is the one they will be validating when they click on the validate button. The code nicely redirects to the W3C validator site file upload page but of course with no post data.

And no, this doesn't necessarily have to happen within JSF. But the backend Java code is the one that reads the appropriate file the client will be editing.

Thank You!
James
 
Danger, 10,000 volts, very electic .... tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!