Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
|
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 5th, 2009, 09:29 AM
Registered User
 
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default how can I define sevral session in my project?

I want to have several session in my project .but I can't define more than one session in it.when I want to define more than one session I have error.
please quid me how can I define more than one session in my project?
thanks.
 
Old March 5th, 2009, 09:36 AM
Registered User
 
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default you can use addURL() method in shine j2ee framework instead of using session

you can use addURL(param,value) method for your problem.
you can use addURL() method to have any session that you want.
in fact it's not a session.addURL() method working like a session but it's better than a session.
you can find this method in shine j2ee framework.

I am sure that you have worked with Session, Application in JSP and FormBean in Struts. Utilizing each of them has the own special problems. Disadvantages of utilizing the above mentioned cases are traffic bar in Ram level, complicated codes and boring.
As we addressed in the previous article, on the contrary to Struts, in Shine, you can use the URL parameters in the services.
For example, you can send the name's contents to the mapping class via one URL, and after the processing the name's contents, guide the user toward a service, you can use the URL's contents again in the considered service. This process was not possible in Struts, and not now, you have 3 principal options for doing this process in Struts.
1- Utilizing the Session: making busy the server RAM.
2- Utilizing the Application: limited utilizing
3- Utilizing the FormBean: establishing some extra classes
It is done easily in shine; you can use easily URL's contents in considered service again in shine. But, it is not finished yet.
For clearing the case, we give an example. You have made a HTML form in which there is a context filed which is titled famil. When the user submits the form, the functional program will guide him/her toward the mapping class. In the mapping class, the amount of received URL which contains the famil has been considered, and user is guided toward the special service.
In the considered service, the famil amount has been received and displayed twice; this is what the shine does!

There is a small problem, assume that you need to produce amount and send it to the considered service in the mapping class. this amount does not exist in the HTML format! Mapping class undertakes to produce this amount.
In the mapping class, you can not use Application, Session and FormBean.

Code:
package view;
import J2sos.shine.controller.Mapping;
public class ClassicMapping extends Mapping
{
Public void rater()
{
Request.getSession.setAttribute("name","ali"); //this is false
Forward("service2","tag1");
}
}


As you see, the above mentioned function is not possible in shine, but be careful that there is a much loveable creature which is titled URL.
In the mapping class, you are able to add an amount to the URL easily and guide toward the considered service.
I give an example regarding the above mentioned case, in order to clarify the matter:
Assume:
You have created an HTML format, in which there is a context field which is titled famil, when the user submits the form, the functional program guides him/her toward the mapping class, in the mapping class, the received URL's amount which contains the famil's amount is considered and the age will be created, and after doing this process, the age will be added to URL, and the user is guided toward a special service. In the considered service, the famil amount and age are obtained from URL and displayed for it.
Come to observe the amounts of URL's parameters before entering the mapping class:
Famil=fowloer
Now, come to observe the amounts of URL's parameters after exiting the mapping class, and before entering the service:
Famil=fowloer&age =23

Be careful that there is no limitation in utilizing the method of addURL , you could use session just one time, but you can use this method , pay attention to the following example:
Code:
package view;
import J2sos.shine.controller.Mapping;
public class ClassicMapping extends Mapping
{
public void rater()
{
addURL("age","23");
addURL("name","amir");
forward("service2","tag1");
}
}

In the previous example, the famil's amount was sent through form and URL to the mapping class, when the code is done, age=23 and name =Amir is added to URL, now you can receive amount, name, age and famil in the considered service 2 and show it to the user.
With the above mentioned method, you have used URL instead of application, now come to use URL instead of session.
Code:
package view;
import J2sos.shine.controller.Mapping;
public class ClassicMapping extends Mapping
{
public void rater()
{
addURL("age","23");
addURL("name","amir");
if(request.getParameter("famil").equals("fowler"))
{
forward("service2","tag1");
}
else
{
forward("service1","tag2");
}
}
}

In the above code, the age and name will be added to URL in any condition.
If the user famil will be equal to fowler, the amount of sent URL to service 2 will be as follow:
Famil=fowler&age=23&name=amir

If the user famil will not be equal to fowler, and for example, it would be equal to bahador, the amount of sent URL to service1 will be as follow:
Famil=bahador&age=23&name=amir
Now, pay attention to the following code:
Code:
package view;
import J2sos.shine.controller.Mapping;
public class ClassicMapping extends Mapping
{
public void rater()
{
addURL("age","23");
addURL("name","amir");
if(request.getParameter("famil").equals("fowler"))
{
forward("service2","tag1");
}
else
{
addURL("address","newyorl");
forward("service1","tag2");
}
}
}

If the user famil will be equal to fowler, the amount of sent URL to service 1 will be as follow:
Famil=bahador&age=23&name=amir&address=newyork

With utilizing this method, you do not need Session, Application and FormBean.

you can download shine framework in:
http://www.j2sos.org/download/shine.rar





Similar Threads
Thread Thread Starter Forum Replies Last Post
Define:Push and pop ZORCH Perl 1 April 27th, 2007 10:17 AM
How to define .tld wesleygch JSP Basics 1 April 10th, 2007 07:54 AM
Can u define difference ? gvcc_neel .NET Framework 2.0 4 October 10th, 2005 04:56 AM
Please Define SDK eberly General .NET 2 April 10th, 2005 04:49 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.