Question

How to open a new window with a new session scope?

Asked by: jarasa

Hi All

Does any of you know if is it possible to open from a browser a new window to the same Server but with different session as if you did it from the system?

Not sure if I've explained it well, if need more details just ask fot them.

:c))

Javier

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-03-25 at 08:29:04ID20932001
Tags

new

,

session

,

open

,

window

Topic

Java Server Pages (JSP)

Participating Experts
3
Points
500
Comments
30

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Session API
    Hi, can anybody explain how the session creation works ? - If I create a session with request.getSession(true), where is the relevant Cookie saved ? - Does the Servlet API or the JServ create the session ? - Where is the session data stored ? - What happens, if i open ...
  2. Session
    Hi all, If I close my browser ( such as Internet Explorer ) suddenly , how can i know that session has died ? Actually , that session has not died , I just want to recognize when they close IE suddenly .

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: rrz@871311Posted on 2004-03-25 at 08:47:44ID: 10678698

Are using cookies or URL rewriting  ?  
I don't know if you have access to the third edition of Hans Bergsten book  "JSP"
but on page 139 he writes about this  subject.  You might be able to get what you want if you use URL rewriting  and  avoid using cookies.

 

by: jarasaPosted on 2004-03-25 at 09:01:29ID: 10678844

Hi rrz.

We don't use cookies, but what you mean with URL rewritting?

Javier

 

by: kennethxuPosted on 2004-03-25 at 09:35:03ID: 10679216

>> We don't use cookies
your servlet container does! http is stateless. so the container will have to find a way to maintain a session. there are two means that every servlet container supports (required by spec), cookiee and url rewrite.

cookie is used by default, the container will set a cookie named, for example jsessionid. when you open a new window, they belongs to same browser process, the cookie is shared so you cannot have 2 different sessions with one cookie.

url rewrite requires programming efford, you need to make sure every url you placed in your page are uncoded by response.encodeURI(), which add extra info to the link so container will be able to extract session id from the link to maintain a session. as a side effect, if you don't use encodeURI when you open the new windows, you automatically get a new session.

all above should be described in the book that rrz recommended.

 

by: jarasaPosted on 2004-03-25 at 09:44:07ID: 10679324

So that means that if I disable cookies on the browser each time I open a URL the server will create a new session, right?

But there is no way that you can disable cookies programatically.

Javier

P.D.: Thanks for the boolean thing :c) I'M SILLY!!

 

by: kennethxuPosted on 2004-03-25 at 09:49:53ID: 10679400

correct!
>> But there is no way that you can disable cookies programatically.
you can force server to not use cookie.

 

by: jarasaPosted on 2004-03-25 at 09:54:52ID: 10679458

>you can force server to not use cookie.
You can do that on the code, or just on conf?

I have to go, follow your answer tomorrow.

Javier

 

by: kennethxuPosted on 2004-03-25 at 09:57:04ID: 10679482

>> You can do that on the code, or just on conf?
config

 

by: rrz@871311Posted on 2004-03-25 at 20:02:59ID: 10684128

I tried to do what I suggested in my first post. But I failed to find a way to do it.  

>if need more details just ask fot them.
If kenneth's suggestion doesn't work for you, then please do give more details.
What Objects did you want the session to hold ?

 

by: jarasaPosted on 2004-03-26 at 00:46:34ID: 10685192

Well the point is that we have an application that creates a session on loging and so on, what we want to do is to be able to open a different session from the same browser like if you open a new browser from the systema and log in again, but normally browsers mantain the same session if you open a new window from it. I thougth about making a call to the system and open a new browser with the URL but I'm not really sure if that canm be done in all systems, I can do it on windows and IE but not sure if will work with linux or NS or Mozilla. That's why I asked the question here.

Javier

 

by: TimYatesPosted on 2004-03-26 at 02:13:53ID: 10685685

kennethxu is right, you will need to disable cookies and rewite the URL for this...

> I thougth about making a call to the system and open a new browser with the URL

You can't do this on a client's machine...

 

by: TimYatesPosted on 2004-03-26 at 02:14:44ID: 10685688

 

by: jarasaPosted on 2004-03-26 at 03:09:48ID: 10685991

Hi Tim.

Thanks for the link, it looks interesting.

>You can't do this on a client's machine...

You can, but this is in Windows and IE don't think it will work in other systems and if the client does not have IE it wont work for sure, you can check the browser that the client uses and try to open a copy of it but....

<html>
<head><title>Open new Browser</title>
<script language="JavaScript">
function openNewBrowser() {
      var Shell = new ActiveXObject("WScript.Shell");
      Shell.Run("Iexplore.exe http://www.google.com");
}
</script>
</head>
<body>
<script>
openNewBrowser();
</script>      
</body>
</html>

Javier

 

by: rrz@871311Posted on 2004-03-26 at 06:24:36ID: 10687318

Javier thanks for sharing that windows code.  

I tried the code posted by garthman ( pointed to by Tim's link above here).  
I couldn't get it to work. I doubt it would ever work. But I would loved to be proven wrong.    

Have you considered using application scope and  implemneting your own  pseudo-sessions ?  If you like that idea (hack hack)  then I would like to help you in trying to implement it.     rrz

 

by: kennethxuPosted on 2004-03-26 at 10:09:16ID: 10689567

>> I tried the code posted by garthman
you need to disable cookie session tracking in tomcat server before you can use url rewrite.

 

by: rrz@871311Posted on 2004-03-26 at 17:07:40ID: 10692612

>you need to disable cookie session tracking in tomcat server  
kenneth, How is that done ?    

 

by: rrz@871311Posted on 2004-03-26 at 17:17:01ID: 10692641

Regarding the link posted by Tim,
seems to me that question contains the same requirement that  Javier has asked for here ( that is why Tim posted the link, I think ). But the accepted answer (by garthman) does not provide a solution.    
Am I right or wrong ?    rrz

 

by: kennethxuPosted on 2004-03-26 at 17:28:34ID: 10692680

If my memory serves me add cookies="false" as a context attrribute in server.xml

 

by: kennethxuPosted on 2004-03-26 at 17:29:13ID: 10692683

sorry, I'm really busy at this moment :-(
can somebody check tomcat doc and verify this? thanks!

 

by: jarasaPosted on 2004-03-30 at 01:41:38ID: 10712097

Thanks for the Help guys !!!
Has been my first question here !!!

Javier

 

by: rrz@871311Posted on 2004-03-30 at 06:44:19ID: 10713847

Thanks for the points, Javier, but knowledge of how you solved your problem would be more valuable.   Specifically I would like to know what you thought of garthman's solution( see link posted by Tim).  Also did you find out how to  disable cookie session tracking in the tomcat server as suggested by kenneth ?   If you want points for your extra time, then I will pass some to you.     rrz

 

by: jarasaPosted on 2004-03-30 at 06:52:22ID: 10713917

Hehe I want no points rrz :c)

Actually I'm not really sure if is solved or not, was a question the ask me here at work and I just posted the question and delivered your good advices, I'll let you know once they tell me how did they've done it.

I just gave the points becose I think it will take some time to them to test all and find out an appropiate solution.

I promise I'll tell you.

Javier

 

by: rrz@871311Posted on 2004-03-30 at 07:27:53ID: 10714244

Thanks Javier, but it is not just for me, it is for all readers of this database. Please think of all those that will search and find our posts in the future.  Everyone is here to learn.  rrz

 

by: jarasaPosted on 2004-03-30 at 07:31:57ID: 10714287

I know rrz and Always post the solutions, you know that, just that I don't already have it, to tell you the truth I'm affraid that Kenneth warns me becose I don't close my questions.

:cP

No serious I'll do it right away I know it.

Javier

 

by: kennethxuPosted on 2004-03-30 at 10:19:24ID: 10716024

>> Specifically I would like to know what you thought of garthman's solution( see link posted by Tim).

What garthman was posted is correct. actually, you should always encode your internal url if you are going to put up on html page, include links and form action. That way, you'll have your session preserved regardless of whether user agent allows cookie.

I also check the tomcat doc and yes, that's the way to disable cookie session tracking.

>> I'm affraid that Kenneth warns me becose I don't close my questions.
Am I that bad :-(

 

by: rrz@871311Posted on 2004-03-30 at 12:33:51ID: 10717439

kenneth, thanks very much for your time here. I know you have been quite busy.  
In order to sort this matter out, I put the following two lines on my pages.

fromUrl??<%=request.isRequestedSessionIdFromURL()%><br/>
fromCookie??<%=request.isRequestedSessionIdFromCookie()%><br/>  

Of course the initial response(in either browser) is always
fromUrl??false
fromCookie??false  
because the user agent has not joined the session yet and the session is new.  

>I also check the tomcat doc and yes, that's the way to disable cookie session tracking.
Yes, I agree. But I could not get the IE6 browser to agree.  

In Netscape 7.1  cookie control is finer.
So, I can deny the session cookie and  results in second page are  
fromUrl??true
fromCookie??false  

But in IE6 I could not get those results under any circumstances( but please prove me wrong).
Even using "Advanced Privacy Settings"
and checking both "overriding automatic cookie handling" and "block" all cookies.
The results in IE6 are always  
fromUrl??false
fromCookie??true    

Please comment.    rrz

 

by: rrz@871311Posted on 2004-03-30 at 12:39:06ID: 10717489

My second page, is what garthman called   NewPage.jsp.    rrz

 

by: kennethxuPosted on 2004-03-30 at 12:44:41ID: 10717553

I'll find time to test, no promise on date and time :)

 

by: kennethxuPosted on 2004-03-30 at 19:06:49ID: 10720533

It works for me. I have tomcat 4.1.18, used the examles context. tested before and after set cookies="false" in server.xml
No setting change in IE6 and it works. You might want to clear IE cookie and test again.

a.jsp:
<% session.setAttribute("test", "This is a test string" ); %>
<a href="<%=response.encodeURL( "b.jsp" )%>">b.jsp</a>

b.jsp:
test attribute: <%=session.getAttribute("test")%><p>
fromUrl??<%=request.isRequestedSessionIdFromURL()%><br>
fromCookie??<%=request.isRequestedSessionIdFromCookie()%><p>  
<a href="<%=response.encodeURL( "b.jsp" )%>">b.jsp again</a>

 

by: jarasaPosted on 2004-03-30 at 23:47:55ID: 10721684

>Am I that bad :-(
I'm totally sure you're not.

My colleges are trying to implement the Javascript method I told them, becose they just want to create a new seesion on a special link on their application, as if they set cokies to false on the server they must encode all their URL and that will be too much work since is a production project.

I guess they should figured it out before they started the develop of it but no is to late to make that huge change.

But I think is a good thing to know all this we're talking about, I'm gald I asked this question I've learned a lot.

Thanks again to all of you.

Javier

 

by: kennethxuPosted on 2004-03-31 at 07:46:20ID: 10724547

it's good to refresh my mind on that. thanks to your too, Javire.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...