Making  a session in jsp.

I want ti make a session in jsp.
suppose if any budy can login through login page which is
www.harshworld.info/login.jsp
they will just direct open that page
www.harshworld.info/wallpage.jsp
then this page will not open . & user will see The login page it self.
So after making session in jsp what can i do ?
& how to Do can one help me.
PL Thanks for Giving time to me

THk dear
there's always a session...
if(session.getAttribute("username") == null) {
response.sendRedirect("login.jsp");
return;
and put the attribute in the session on successful
login..
Or look up other security modes.

Similar Messages

  • Session in JSP page

    Hi all,
    i built a web application now i want to use session in JSP pages to remember some variable such as password and entered date because i need them in later pages and i also don't want to send them via HTML hidden field. I actually don't know how to use session. Can anyone please just tell me how to create a session and store a variable and also how to retrieve the data from the session.
    Another thing is guys can anyone tell me please that say i am user and i selected some items from a HTML select list and i submitted that and logged off the system now when i login later again i want to see those choices selected by default , i know it might have been done by sessions can anyone please tell me.
    THANKS VERY MUCH

    This is the way u can set and retrieve values from session
    <% session.setAttribute("key","value"); %>
    <% String user=(String)session.getAttribute("user");
    %>
    regards
    Shanu

  • How to Handle user Session in JSP

    Help me,
    How to handle user session in JSP.......

    Prakash_Pune wrote:
    tell me some Debugging tech. so i can overcome from my problem.....Do you use an IDE? Any IDE ships with a decent debugger where in you can just execute the code step by step, explore the current variable values and check what exactly is happening. For example Eclipse or IntelliJ. If you don´t use an IDE, then just place some System.out.println() or Logger.debug() statements at strategic locations printing the variables of relevance so that you can track in logs what exactly is happening.
    or tell any other way to find is my page is thread safe or not...Just write correct code and narrow the scope of the variables as much as possible. If you for example assigned the user object to a static variable or as a servlet´s instance variable, then exactly the same user object would be used everywhere in the application. That kind of logical things.

  • How to clear session in JSP?

    I searched yahoo, and found that it seemed not easy to force invalid the session using jsp, compared to php just three lines:
    session_start();
    session_unset();
    session_destroy();
    How to acheive this using JSP? Must I follow these (quite complex) steps like this one?
    http://sdc.sun.co.jp/javasystem/technote/cluster/jsp.html
    Any simplier method?
    Thx.

    Not at all, it's very simple.
    <%
    session.removeAttribute("attributeName");
    %>
    This HttpSession API document shows all methods that can be called on the session object : http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSession.html

  • What is the use of session in jsp

    hai,
    what is the use of session in jsp. i cant understand from books. give some practical approach
    thanks

    give some practical approachYou sound like a supervisor ordering for a cup of coffee.
    I DONT TAKE ORDERS !!
    IMAO
    Which book did you refer ? Did you google ?

  • Want to get ApEx session in JSP

    Hi Pals,
    From my ApEx application, I am calling a JSP by providing a direct URL.
    THe JSP does some specific function here.
    If the user get the JSP url by right click and view source, they can very well use this outside my ApEx application.
    I want to apply security like, the JSP url only works inside my ApEx application.
    My thought, if I can share ApEx session with JSP session I can impose the security check in JSP level.
    Any idea would be appreciable.

    Hi,
    Im using below method to call jsp page and passing UserName, application id and Session as
    <iframe src="http://apex.oracle.com/pls/otn/...javaapplication.jsp?userId=&USER.&appId=&APP_ID.&sessId=&SESSION."></iframe>
    Vailidation is done against the table "wwv_flow_sessions$" of schema : flows_030100 ,whether those values are exist in table.
    But if user is already logged into apex application, he can run the jsp independantly taking the url from "view source".
    Im also looking for more solid validation
    Regards,
    Benz

  • Handling Session in jsp and bean scope

    i have problems with handling session in jsp
    I want to check on all jsp pages
    first thing is session is null
    i want to him to be redirected to first page
    and he should not be able to go ahead
    I tried
    if(session ==null)
    response.sendRedirect("Login.jsp");
    but this does not seem to work
    It is very crtical problem can any one answer
    this asap
    Also i wanted to know that
    I have bean which in turn calls static methods of another class which holds all DomainTable(database tables which do not change frequently)
    Information .
    This is bean is being implemented by me
    in seession scope in a jsp
    Do u guys think it would be goo idea to change
    scop of this bean as Application in jsp
    if so what would be advantages for same
    I would appericate if i could a quick reply on both
    question
    as i am time crunch
    arsh

    You will always get some value of session and your code wont work. At the end of your Login.jsp, you should create a sesssion and store attributes. Check for these attributes in session, rather than checking session==null.

  • Maintain session in JSP frame

    Hi,
    I am having trouble in maintaining session in jsp frames. -
    Here is sample code
    parent.jsp
    <HTML>
    <HEAD>
    <LINK rel=stylesheet type="text/css" href="defaults.css">
    <TITLE>abc</TITLE>
    <%     
         String checkAmount = "100.00";
         session.setAttribute("checkAmount", checkAmount);
         System.out.println("checkAmount in ppmain"+session.getAttribute("checkAmount"));
    %>
    <FRAMESET rows="235,*" frameborder="no" >     
    <FRAME NAME="pptop" SRC="top.jsp" frameborder=0 scrolling=no noresize >
    <FRAME NAME="ppbottom" SRC="bottom.jsp" frameborder=0 scrolling=no marginwidth=0 marginheight=0 noresize>
    </FRAMESET>
    </HTML>
    top.jsp -
    <HTML>
    <HEAD>
    <LINK rel=stylesheet type="text/css" href="defaults.css">
    <TITLE>top</TITLE>
    <%     
    System.out.println("session in top "+session);
    System.out.println("checkAmount in top "+session.getAttribute("checkAmount"));
    %>
    </HTML>
    It is not able to retain session in the top.jsp ( in SOP for session I get different session ID in parent.jsp and top.jsp
    This Works well in local but when gets deployed to WAS6 server troubles starts.
    Any help is appreciated.
    Thanks

    When you create URLs, you might want to try using JSTL to rewrite them:
    <FRAME NAME="pptop"
           SRC="<c:url value='top.jsp'/>"
           frameborder=0
           scrolling=no
           noresize >
    <FRAME NAME="ppbottom"
           SRC="<c:url value='bottom.jsp'/>"
           frameborder=0
           scrolling=no
           marginwidth=0
           marginheight=0
           noresize>Or you can use:
    SRC='<%= response.encodeURL("top.jsp") %>'

  • New session in JSP?

    I'm currently working in a project that's basically a search-engine. The
              application is running on BEA's WebLogic server and the logic is placed in
              JavaBeans and EnterpriseJavaBeans. The JavaBeans that I access from my
              JSP-pages has the scope set to 'session'.
              As long as every user runs the application in different webbrowsers
              everything is fine, but if I open a second window (pressing Ctrl+N in IE) it
              seems like I'm stuck in the same session which means that I've got two
              references to the same object of my JavaBean.
              The outcome is that I either get the same result from two different querys,
              or that my application crashes. The server executes the querys in different
              threads, but since the EJB that holds the result is a stateful sessionbean
              the result is dependet on the last query.
              Are there any way of detecting that a request is made from a new window in
              the same browser (http-headers?), and creating a new session? Are there any
              way at all to force a client into a new session?
              /Johan
              

              "Johan Kindgren" <[email protected]> wrote in message
              news:[email protected]...
              > The database that we searching in contains about one million rows in
              several
              > tables, and the design-specification we've got demands that 90% of the
              > querys should return a result within three seconds, from anywhere in the
              > world.
              > Our idea to solve this is to divide the application into three layers,
              where
              > the first one is the JSP and JavaBeans. The middle layer is our stateful
              > sessionbean and the last is an stateless entitybean that executes the
              > querys to the database. When a query is made, the entitybean returns an
              > array of id's to the stateful sessionbean that match the query, and
              > sessionbean then retreives details from the database in batches of 15
              > records.
              > With this design it takes less than half a second to retreive the next
              batch
              > by making a query from id's, instead of making a query from a name (which
              in
              > worst case can take up to a minute right now, we have not optimized the
              > database yet).
              >
              > The JavaBean that I use in the JSP-pages creates a connection to the
              > sessionbean, and this connection is kept throughout the session.
              To fix your initial problem, you should assoicate your stateful session
              beans with a HTTP request rather than a HTTP session. This will get around
              your current problems (crashes & synchronisation). Or a more complex
              approach could be to remove the EJB from the HTTP session before you use it
              (so that no other request can use it at the same time).
              Browsers can and will make multiple concurrent requests with what appears to
              be (from the Servlet engines perspective) the same HTTP session - so don't
              associate a stateful session bean with a HTTP session. Associate it with a
              request instead. (In fact this is true of any EJB).
              >
              > If I understand your suggestion correct, we would have to skip the middle
              > layer. I suspect that we would have significant loss of performance in
              that
              > case. Are there any way to work around this? Any ideas in another design
              > that would eliminate this problem?
              Layering is often useful. The trick is to layer things correctly. I don't
              really have the bandwidth to understand your use cases correctly to
              formulate the correct architecture to follow. I'll give you a brief 30,000
              foot view of how I tend to do things...
              Briefly, I've never been terribly convinced of the value of entity beans at
              all. I personally think they are a bit of a mistake because they are remote.
              I far prefer the JDO idea which will hopefully replace entity beans one
              day.(http://access1.sun.com/jdo/) Generally the current thinking is that
              whether you use JDBC, JDO or Entity Beans - they should be wrapped inside
              session beans anyway. So from your layering perspective, entity beans are
              implementation detail inside the session beans layer.
              Mostly the client side wants go get 'data objects' back from queries which
              can then be used to do other navigations / queries / operations. It also
              helps to have client side helper beans to abstract the complications of
              using session beans (handling lookups, pooling, timeouts etc.).
              So the layers I prefer to focus on are
              Server side: Session beans - implementation I don't care - maybe internally
              using entity beans or JDBC or JDO. These should be stateless wherever
              possible. Should return Java beans to clients.
              Client side: Java beans - wrap use of session beans
              (timeout/pooling/creation stuff and sesion bean API). These client side Java
              beans often pass client side state (e.g. user id) into sesssion bean methods
              to allow the session beans to be stateless. Usually the client side will
              include Servlets, JSP, custom JSP tags here too.
              The Session beans on the server side may be split into the main stateless
              session beans that do most of the work with some small stateful session
              beans for doing things like query paging etc - though I've often found its
              easy to do this in stateless beans with a clever caching model.
              > The application will serve about 30 concurrent users, but there are a tota
              l
              > of 400 users.
              Though the same user may use multiple web browser windows on a desktop, so 1
              real user can become several concurrent users.
              J.
              James Strachan
              =============
              email: [email protected]
              web: http://www.metastuff.com
              

  • Does the session of JSP limit the capacity?

    hi,all,
    I write a JSP program,and I need to put many Vectors into the session.So I am eager to know whether the session has the limited capacity?If there is too much things in the session, will the performance of running be down?How could I do?Thanks!

    Hi
    Storing a lot of objects in Session might slow down the application depending on the load you are expecting and the resources your application server has at its disposal.
    There is no definite answer , you have to look at the application requirements and scope out the variables you may have to share at various levels - application, session, request, page etc. The trick often lies in the design of the application so that you are not making a particular object too bulky.
    As far as how to deal with your particular problem it is hard to say without looking at the requirements. If you have to put very large vectors/Objects into your session then you may have to rethink your design.
    One suggestion here is to store the Data in Collections instead of Vectors as the Vectors are costlier in terms of processing than Collections. Collections are part of the java.util.* package.
    Keep me posted on your progress.
    Good Luck!
    Eshwar Rao
    Developer Technical Support
    Sun microsystems inc
    http://www.sun.com/developers/support

  • Problem with Sessions in JSP

    Hi,
    I am working on a JSP based website, where I am facing problem with sessions. The user is asked to login by providing her id and password. If found correct, a bean is created and populated with all her details and placed in session scope. I plan to use the information stored in the bean on other related pages until she logs out.
    <jsp:useBean id="validUser" scope="session" class="UserBean" >
    <c:set target="${validUser}" property="userId" value="${fn:trim(dbValues.UserId)}" />
    <c:set target="${validUser}" property="userName" value="${fn:trim(dbValues.UserName)}" />
    </jsp:useBean>
    <c:redirect url="userHome.jsp" /> The user is presented her homepage - 'userHome.jsp', where she can find various links, like 'Update Profile', 'Pay Registration Fees', 'Book Room' etc. The information stored in the bean is available on 'userHome.jsp'page.
    <A HREF='userHome.jsp'>Home</A>
    <A HREF='editPersonal.jsp'>Update Profile</A>
    <A HREF='registrationFee.jsp'>Pay Registration Fees</A>
    <A HREF='bookRoom.jsp'>Book Room</A>
    <A HREF='logout.jsp'>Logout</A> The problems are:
    1. Whenever user clicks on any of the above mentioned links and moves to any page, the bean comes out as null.
    <%-- Verify that the user is logged in --%>
    <c:if test="${validUser == null}">
    <jsp:forward page="loginForm.jsp">
    <jsp:param name="origURL" value="${pageContext.request.requestURL}" />
    <jsp:param name="errorMsg" value="You must be logged in to access this site." />
    </jsp:forward>
    </c:if> 2. The URL shows an additional jsessionid, which my client doesn't want to see.
    3. On every click on any link, the value of this jsessionid changes.
    What I presume, when I am clicking on different links, my session changes, and so I am seeing a different jsessionid. And since session is changing, therefore the bean is not available in a different session.
    All this works fine with localhost, problem comes into picture, when I upload my pages to the server.
    Puzzled, can anyone help, where am I going wrong? Let me add here, I am new to JSP and hence don't have much resources with me.

    There are several ways sessions can be exchanged between the browser and the server in a j2ee web application.
    1. The default is through cookies. However when the client does not accept cookies, the server appends the session id to the url.
    2. Some servers also facilitate session information exchange using session id in the url even if the client does accept cookies. This is usually ahieved through a setting in some server configuration file.
    You will have to find out why the server in your application is appending the session id to the url.
    Whatever be the case, the server should be able to look up the session from the incoming request (be it from the session id in the url or a session cookie).
    When session information is exchanged through the JSESSIONID in the url, you should ensure that each and every url that goes to the server has this input parameter. To do that all links and form post urls in your servlet/jsp should be treated with a call to encodeURL().
    For example, in a jsp
       <a href = "<%=response.encodeURL("/nextJsp.jsp")%>">Click here </a>
    or
       <form action = "<%=response.encodeURL("/nextJsp.jsp")%>">
       </form>etc.
    ram.

  • How to create a new session in JSP file

    Usually a child IE window uses same session with parent window. Dose someone know how to create a new session when creating a new IE window by clicking a URL in parent window? The web page is writen by jsp file.

    I am not sure of your question. Are you wanting to have 2 Session objects (one for the parent window and another for the child)?
    A session is usually created once per client and is stored on the server the session id is carried around in a cookie or a URL rewrite so that everytime the user submits a page you will be able to store/access information.
    // this will create a new session object if one doesn't already exist.
    HttpServletRequest.getSession( true );
    Hope this helps

  • Session Timout JSP Page Forward

    Hi All,
    I am currently working on a JSP site and want to add a JSP page forward that takes place when the user's session times out after a period of inactivity.
    I have created a servlet that implements HttpSessionBindingListener and has methods in place for valueBound and valueUnboud. The methods are getting called as they should, however because there isn't an HttpResponse object I cannot do a response.forward....
    So my question: Is the HttpSessionBindingListener the correct interface to be implementing to accomplish my goal? If so, how do I forward the user to the login page? If not, what should I use and how do I forward the user to the login page?
    Thanks for your time and help.
    Aaron

    valueUnbound method? Arent you using a Model
    View Controller type architecture? The servlet
    is mainly used to to handle logic and navigate
    to the appropriate view(your java server pages).
    The code I supplied should be placed in the service
    method of your servlet.. then it can handle the
    request and determine where to go from there. Your
    servlet should have three methods, the doPost, the
    doGet, and the service method. The doPost and Get
    should pass the request and response objects on to
    the service method. Any other logic should be handled
    in other classes that you create. The service method
    basically decides what the next page should be.
    Hope this helps..

  • Session in JSP

    Hi all,
    I used session in my JSP pages. Now when user click Logoff link the page goes to a JSP page and there i invoked
    session.invalidate();to end the session.
    On that page there is a link to login again.
    If the user use that and then login with a different ID and store some info in database it still shows previous users ID meaning that session is still getting old value although i invalidated it.
    Can anyone please help me.

    Hi CodeYoda,
    Thanks for reply. I tried your code but still it doesn't work.
    Now let me explain the situation, When i turned the machine this morning and started tomcat and run my application with a different ID, and i did some updates in database and it still shows the ID that i used when i created the session couple of weeks back.
    Now i think this is a serious matter because it remembrs that ID only.
    Now let me clear the concept again. my jsp pages are not linked by data transfer but they have links of all pages on the menu in every page so when they login and in the second page i stored the login name in session after that i used it in a page which has no connection with any other pages. Now what i did is i made the page available for session and then i used the login name.
    Now is that mean that the login name is stored in that pageforever and since it doesn't send anything to logoff page and when we kill the session inlogoff page it is only killed in logoff page. That's my assumption. Can you please confirm me.
    Thanks

  • Error in accessing pageContext or current session for JSP/servlet in frames

    I am creating a web application on iPlanet application server (ver 6.0 SP4) and display a page
    consists of frames in web browser (IE6). The framset and the content of each frames are
    JSPs or servlets. There where no problem to display each content frames individually at all.
    However, when the overall page (the frame set and the 3 frames) is displayed, the following
    problem occurs.
    Only the outermost frameset and just one or two of the frame contents displayed successfully
    in browser. Others have either 1 of the following errors:
    1. When accessing pageContext object in _jspService routine when displaying the JSP page, Null
    Pointer Exception occurs:
    java.lang.NullPointerException
    Exception Stack Trace:
    java.lang.NullPointerException
    at jsp.APPS.intl.acct_type_option._jspService(acct_type_option.java:653)
    2. When calling the req.getSession method in doGet() method for servlets, the following
    exception occurs:
    Exception in doGet(): This session has already been invalidated
    The occurance of error is random among all the frames. With the frame on top or left size
    having the most chance to be displayed successfully.
    It seems that the Application server cannot entertain 3 or 4 requests simultaneously (which
    happens when displayed a page consists of frames), having some of them throw an exception.
    Are they any tuning or setting for iPlanet server to overcome this problem?

    I'll give you the same advice as I have been given regarding the use of frames.
    Don't use them at all. Use scrollable DIV's instead.
    The use of frames is such that you would have different JSP's who cannot collaborate together since each is in his own frame and does not know about the others.
    In case I'm mistaken, I'd like to hear about it, but the combination of JSP's and frames is an unhappy one.

Maybe you are looking for

  • Hyper-V could not replicate changes for virtual machine 'machinename': The connection with the server was terminated abnormally (0x00002EFE).

    I have a 3 node cluster that has replica setup to replicate to another cluster off-site. Suddenly one of the servers is not replicating with the error: Hyper-V could not replicate changes for virtual machine 'machinename': The connection with the ser

  • Problem in downloading data from application server

    Hi, I tried the following code for downloading data to PC in background: PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY. OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. IF sy-subrc = 0.     LOOP AT itab INTO istab.       TRANSFER is

  • Importing flash with AS3 external files

    developing a ui in flash for photo gallery which I am loading into dreamweaver. using as3 in flash to load external photo files so not all having to download on opening. have had no problem in dreamweaver with swfs with embedded jpgs. ui comes up in

  • How do I get my phone off of 1x and back to 3G?

    I am fed up with my phone/service!!! It is for the most part constantly at 1x for service instead of 3G. The only time that I canuse apps, send texts, use the internet, make phone calls, etc is when I am on wifi and that is not always possible.  I ha

  • Replication - Single Master DB

    Hi I have a DB running on Server 1 and I want to create replication of all the Objects(existing Tables and any new table created) from Server-1 to Server-2. I want One-Way replication only and it should be SYNC with SERVER 1, So Whats the best Replic