• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Need to save a response , before sending it th the client

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BackGround :
The application has a WebPage [ customizePage.jsp ] , which allows users to specify some customizations . [ specify the number of textBoxes , values in dropDown etc . ] .

This webPage then makes a call to a servlet , which creates these elements at runtime .

So say like the user specifies , 5 textBoxes at runtime . So this number 5 is passed to the servlet in form of a Parameter .
Then in the java code , within a loop , five new textboxes would be created

These would be set in five different attributes , as Strings

The request and response are then sent to a jsp [ createdPage.jsp ] , using "Request Dispatcher" .

At runtime this code works fine and , fixe new TextBoxes are visible on the browser , using JSP expressions / scriptlets


Problem / Question :
Once the page is created . I want it to be saved . as in next time , instead of going through the entire process , one could simply access "createdPage.jsp" and it would show the final page . [ complete with 5 text boxes ] .
I am not sure how would i save the response .
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why?
 
Roshan Khandelwal
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm... nice ques!!! :)

Anyways i guess , the idea is to allow one user to set up a page and then allow all others to simply use that page . Something that the template kind of websites allow you to do .

So i save the response once and then publish a link for it , which can then be used by others .

I was working on it and realized that i could simply save the request [ final request for the createdPage ] . So next time someone requests this published link , we replace the incoming request by the saved request , and send it in the RequestDispatcher object , which then shows up the setUp page .
 
Ranch Hand
Posts: 147
Eclipse IDE Tomcat Server Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rather than save the request, why not create a bean (or POJO) to store the submitted data? Then you could serialize it to the filesystem on the server for later use, as you suggest.

 
Roshan Khandelwal
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm.. lets see.. Creating a POJO or a bean . But then i don't know which are the attributes or how many of them . So then there would be only a TreeMap , with the attribute Names as keys and the elements generated as values .
Managing that would obviosuly be a bit easier , than the present way of writing the individual ones in a text File . :(

However saving the request is also something that i am yet to achieve . Should i get an "InputStream" from the request and then reading the bytes write the entire request to a text file .
But then how do i replace the request back ??

I am working on these .

At present i am trying to dynamically add a "function : actually an onChange()" to a runtime created element [ using javascript ] :)
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roshan,

Are you trying to create a JSP TEMPLATE ?

i.e., Do you have any visual designer kind of concept in your application ?

After dynamic generation of JSP form elements,

Then... What would be your next process .. ?

Can you provide some insight on this ?
 
Roshan Khandelwal
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes..!! I would say it's kind of a Visual designer , though not exactly a drag and drop thing . It is actually a kind of far fetched idea right now .

Once the user is through with the cutomization Page , they would Save it . Once this is done the request generated would be saved [ i am still working on it ] .

A Final Page would be created based on the user Preferences and a link would be generated . Now you can distribute this link to anyone and they would be able to access the page .


In a normal scenario , since the FinalPage uses values from the customization page [ User Entered ] , and the page if accessed directly won't have these values so it would be showing blank elements / null .
Hence any request to the final page , the request would be replaced by the saved request and when sent to the requestDispatcher would show correctly .

If that clarifies anything..!!!
 
Vicky Vijay
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roshan,

I guess you are looking for the Application like ORBEON FORMS,


Check out the below reference links...

1. DISPLAYS THE SUMMARY OF FORMS CREATED BY THE USERS

http://www.orbeon.com/orbeon/fr/orbeon/builder/summary

OPTIONS available here

"New" button --> This allows you to create the forms



2. VISUAL DESIGNER - You can create OWN FORMS

http://www.orbeon.com/orbeon/fr/orbeon/builder/edit/9b9be77450bddf6e579c4c06bfb141de


Once you have "SAVED" the forms, this would generate a "LINK" i.e., URL (this is similar to your requirement)

and all users can access the form based on the URL link


I hope your are trying SIMILAR/EXACT kind of concept to this..









 
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- You take the user input and save it into the DB.
- Next time, whenever somebody requests the template, you fetch it from DB , and draw the page.

This looks simple, unless I am missing something.
 
Roshan Khandelwal
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Saurabh : Yes... But is it possible to save the request as such [ HttpServletRequest Object ] , Or would i need to read the inputStream and then the bytes .
and in such a scenario , how do i replace the request i.e. sending the request back to generate the Page .
Because i would need to send it as an object and the request has only inputStreams and Readers .

@ Guru Vijay : Yes this is exactly what i am trying to achieve . Thanks for providing the links . Will serve as a great inspiration .
 
Saurabh Pillai
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roshan Khandelwal wrote:@Saurabh : Yes... But is it possible to save the request as such [ HttpServletRequest Object ] , Or would i need to read the inputStream and then the bytes .
and in such a scenario , how do i replace the request i.e. sending the request back to generate the Page .
Because i would need to send it as an object and the request has only inputStreams and Readers .



Why do you want to play with the request? Is it not possible to implement it using DB? Honestly, I do not understand your way of implementation and I am not sure if it will work.
 
Roshan Khandelwal
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Saurabh : Pete in an earlier Post had also suggested the same thing . [ Using POJOs ] .

Actually i have been unable to understand the statement

Next time, whenever somebody requests the template, you fetch it from DB , and draw the page



Let' see " I fetch records from DB , in a POJO and then replace these values [ using some tag library ] into predefined areas in the jsp page right?? . This way i don't have to play with the request .
 
Saurabh Pillai
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Roshan Khandelwal wrote:@ Saurabh : Pete in an earlier Post had also suggested the same thing . [ Using POJOs ] .

Actually i have been unable to understand the statement

Next time, whenever somebody requests the template, you fetch it from DB , and draw the page



Let' see " I fetch records from DB , in a POJO and then replace these values [ using some tag library ] into predefined areas in the jsp page right?? . This way i don't have to play with the request .



E x a c t l y :)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic