3

I have a web application with a complicated form that:

  1. performs field validation,
  2. converts the value to an input format(array) that is easy to parse for the next page.
  3. redirects the user to the next page (data is passed in the URL)
  4. The next page then loads the data performs the calculations and displays the results.

This is all done statelessly in Wicket. I was thinking about how I had done this. It doesn't feel "right". The conversion to an array and redirect "work" but there has to be a better way.

UPDATE
Why the form is Stateless:
The web application in question shares the server with 2 other web applications. I was running into OutOfMemoryExceptions after deploying a new version of this application. When I would check the Tomcat Manager Application BEFORE I converted the forms to being stateless I would routinely see ~150 or "active sessions". Now that the forms/result pages are stateless I see 5 "active sessions". Which has cut down quite a bit on my memory usage.(I think). I still have a nagging doubt though: https://stackoverflow.com/questions/16049219/how-to-handle-a-hibernate-bi-directional-mapping-for-a-set-properly

Suggestion:
I've started wondering if maybe I should remove the "results" page mount point and convert it into a panel. That way I can just pass my complicated object directly to it and swap panels in a full page refresh. Is that even possible in a stateless page?

POST
Also I don't believe wicket natively supports POST redirect: How to use post method in wicket

Community
  • 1
  • 1
Raystorm
  • 6,180
  • 4
  • 35
  • 62
  • 1
    If you **have to** keep it stateless, the only improvement I can think of is to post the data instead of putting them in the URL. Your page could have two forms, one for your actual validation stuff and another "hidden" one that will be re-rendered on successful submission of the first one and will have user's inputs as hidden fields. The second form will have its action pointing to your stateless page and will be submitted via javascript appended to the ajaxrequest that rendered it. – Lazarus Lazaridis Apr 23 '13 at 11:11
  • Remember to use StatelessChecker to confirm that everything is stateless **(if any of the components or the behaviors are not stateless than the page will revert back to statefulness)**. – Rangel Preis Apr 23 '13 at 13:02
  • If you transport the data (no matter if POST or via GET parameters) *after* validation, you should not trust the data on the second page, as it could have been tampered with. Either you do the validation on the second page, or transfer the data on the server (aka session) – bert Apr 29 '13 at 08:23
  • I've added validation to my array parsing on the second page. However, it is admittedly not as robust as my initial form validation. :( – Raystorm Apr 29 '13 at 17:25

1 Answers1

1

Did you look closely at the OutOfMemoryError? Typically when redeploying an application you run out of permgen space, not user memory. Permgen space leaks are very common and hard to remove. Probably this has nothing to do with Wicket but more with classes that remain loaded. You should try using Java 8 (has no permanent generation), or a newer version of Tomcat (and Wicket) as often classloader leaks are resolved in newer versions of frameworks and containers.

See also this article: Avoiding Apache Tomcat Out Of Memory Errors

Martijn Dashorst
  • 3,652
  • 17
  • 26