velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Ike <jeich...@optonline.net>
Subject Re: This question has "first major web app" written all over it.
Date Fri, 11 Apr 2003 08:21:27 GMT

I understand that you don't need to use the HttpSession, but if doing
web programming and not template processing (though they are one in
the same mostly) you have to place objects within the HttpSession to
have them accessible to the VTL?  I hope that last sentence made
sense....

If that is the case, then this link makes me concerned
http://www.4guysfromrolla.com/webtech/faq/Advanced/faq4.shtml about
scalability.

In my case, I was placing fairly massive objects (Vectors of
information) into each HttpSession so that I could display it.  I
believe that information would be serialized.   Without doing that
processing totally confined within a servlet template merge, is there
any way to get information to the velocity (*.vm) pages without large
object serialization, etc?  I want to just be able to display the
information or place it in form variables, but not store it in the
session and have it serialized.

I know that there is a seperate Velocity's independant Context, but I
thought that was just for internal Servlet merging of templates.  To
get information globally available to my sessions I was using:

        HttpSession session = request.getSession();
        session.setAttribute("TestAction_1_1", "Data 1");

And later in another servlet doing:

        HttpSession session = request.getSession();
        String value1 = (String)session.getAttribute("TestAction1_1");
        log.error("TestAction1(): TestAction_1_1 value=" + value1);

Without (knowingly) doing redirects, the information was not available
in the later servlet doing getAttribute().   Maybe I am doing
something wrong.   Details were in my first message below.

Again thanks.  I am asking maybe stupid questions, but I appreciate
your answers.   I am learning and trying to be intelligent in my
design rather then just plowing through and getting stung later.

John Ike




On Fri, 11 Apr 2003 10:22:44 +0300, you wrote:

>Hi
>Velocity does not require anything to be put in session. If you are talking
>about Velocity's context, that has nothing to do with sessions, or web
>applications. That applies to Velocity in general. If you put something to
>Velocity's context, that something does not go to the http session. It is
>only used when the template is merged with the context data.
>
>Your concern about passing information between pages is a real thing to be
>solved, but it really is not a Velocity issue.
>
>I am also designing and implementing web applications and trying to figure
>out "the right way" to use session information. Right now I think that a
>comfortable compromise with session attributes and serialized (possibly
>stored in db) data is the right way to do it.
>
>As far as your problem is concerned, I cannot help without knowing
>Struts/Velocity usage and how you are trying to pass data. If you store
>something as request attributes, that data is not available accross
>requests, i.e. it does not go to the session, but that you may already know
>:D
>
>- Tatu V.
>
>-----Original Message-----
>From: John Ike [mailto:jeichels@optonline.net]
>Sent: 11. huhtikuuta 2003 9:53
>To: velocity-user@jakarta.apache.org
>Subject: Re: This question has "first major web app" written all over
>it.
>
>
>
>I have like three struts books in front of me.  This is a mixed
>question.  I bring my question up here because the session failing
>part (Problem 1) may be something I am doing wrong in Velocity.
>
>Also I bring it up here cause of my concern for Session balooning and
>serialization.  Velocity alone without need for session objects is
>very fast I am sure, but how does its requirement for Session
>information work with scalability?   How do you bring large pieces of
>data into a web app without putting them into the session and having
>them serialized if they are just for single time viewing?   I am
>trying to use this instead of JSPs, but am new and perhaps asking
>silly questions.  I am concerned as I would like my site to be able to
>scale, but have not seen some of these answers on this mailing list
>and there is such limited information.
>
>I feel in a way this, in a way, is more particular to Velocity then to
>Struts as Velocity forces a strict MVC design which I like.  With JSP
>that is not quite so true, but you also can possibly avoid this
>Session clogging thing a bit....
>
>Anyway, if you have links or advice or code ideas, please let me know.
>I am learning as fast as I can and can use a few pointers.  I like the
>idea of Velocity a lot or I would not be here.  I am really wishing I
>had a more full example that really handles some of these concerns.
>
>Thanks lots.
>
>
>
>
>On Fri, 11 Apr 2003 01:24:06 -0500, you wrote:
>
>>Hi,
>>
>>You might have better luck with this on the struts-user mailing list. I
>>think most of these issues aren't specific Velocity issues - I take it
>>you are using the Velocity-Struts tools with Struts 1.1?
>>
>>If I were you, I'd definitely read a few books on Struts - only because
>>with the type of problems you're having you could check out a complete
>>sample application from the book and get a decent explanation at the
>>same time. The online docs are good, but you're right, they just cover
>>short examples and don't necessarily give you the whole picture.
>>
>>Velocity's just a simple interpreter that translates templates into HTML
>>  (or XML, etc) output based on the Java objects stuffed into its context.
>>
>>Tomcat is the application server - everything runs on top of it. There
>>is some security built into the Tomcat app server with J2EE, but in my
>>opinion, it's useless.  Struts is the tier you want to be looking at for
>>answers.
>>
>>Hope this helps,
>>Jeff
>>
>>John Ike wrote:
>>> Hey all.   My second post here.  I am a somewhat experienced Java
>>> developer, but not a web programmer until now and I am managing to get
>>> myself all befuddled.
>>>
>>> I have a few questions if you have time to take a peek.  I have been
>>> looking for days but can't seem to find the right resources that say:
>>> "This is the way to do it."
>>>
>>> I am creating a Job site where I require logon/logoff/edit profile/add
>>> new services/large querie results to pages.
>>>
>>>
>>> ------  Problem 1  ------
>>>
>>> I have spent so much time trying to figure out the best way to pass
>>> around member related information.   For some reason I seem to lose my
>>> session and I am having a hard time understanding why.
>>>
>>> I follow this chain:
>>>             Welcome.do  --> Welcome.vm --> Logon.vm --> Logon.do
>>>                     --> Welcome.do --> Welcome.vm
>>>                     --> EditMember.vm --> EditMember.do
>>>
>>> I appear to have the Member record stored in session after the logon
>>> and all the way through to the EditMember.vm as information appears
>>> there (unless I refresh at which point it all disappears -- why I
>>> don't know).   When I head to the Member.do, the session information
>>> is totally clear.
>>>
>>> In the *.vm and the Actions, I am using only setForward/setActions and
>>> no redirects.   Session, however, is gone.
>>>
>>> I feel like I must be doing something stupid, but ....
>>>
>>>
>>> ------- Problem 2 ------
>>>
>>> This inability to get session working made me hunt for the last couple
>>> days for an answer.   In great part I spent the time learning.
>>>
>>> In my lookings, I came to this:
>>> http://www.4guysfromrolla.com/webtech/faq/Advanced/faq4.shtml
>>>
>>>
>>> This made me concerned that perhaps I am going about my work the wrong
>>> way today.   Maybe Sessions are not the right means as they may not
>>> allow for scalability.  Concern is of course for need of great amounts
>>> of garbage collection and also need to serialize records.  The artical
>>> seems to feel that URL rewriting is the only way (which means perhaps
>>> also the only way is need for backend database caching mechanism).
>>>
>>> In my first run at my site, I was placing a large ArrayList of job
>>> listings into the session as I could not think of a better way to get
>>> job listings in there in a pluggable kinda way.   Some of the job
>>> listings would be common to all users and some would be specific
>>> queries to individual users.  Thinking about doing this for every user
>>> sounds like a massive serialization and memory risk.
>>>
>>> Can you give me your thoughts on this and what you think I ought to do
>>> in consideration for scalability?   Remember I am a newbie in this
>>> region and am learning on my own about this all.  How big of a problem
>>> is utilizing Session flagrantly and how would Velocity handle non-use
>>> of Session?   Random ideas and thoughts are great, just no throwing
>>> stuff at this newbie.
>>>
>>>
>>> ------  Problem 3 ------
>>>
>>> I am trying to manage authentication/session.  There are so many
>>> options:  Session, hiddin fields, filters, Realms, etc.
>>>
>>> Do you have any links that can point me in the right directions for
>>> answers using Velocity/Struts/Tomcat or have any code I can look at
>>> that handles these concerns?
>>>
>>>  I need to stop guessing about a way that takes into consideration
>>> scalability, session, authentication.   I am capable, but without a
>>> tiny push in the right direction, a bit overloaded.
>>>
>>> I have looked at all the velocity and struts examples, but in general
>>> they are more snippets.   Very useful snippets at that, but not taking
>>> into consideration many of my concerns.
>>>
>>>
>>> I know this is a lot, but thank you for your help.
>>>
>>> John Ike
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>>
>>>
>>>
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: velocity-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message