session in jsp

session in jsp

View Answers

August 14, 2008 at 12:02 PM

Hi friend,

session is implicit object in jsp.


using session oject in jsp.
first u set using following methods

String name="roseindia";
session.setAttribute("user",name); // create session variable with name "user"

using retrive method

String sessionuser=session.getAttribute("user");
out.println("welcome"+sessionuser);

A small application for User and Admin

"login.jsp"

<html>
<head>
<script src="valid.js" type="text/javascript"></script>
</head>
<body>

<form name="loginform" method="post" action="loginmid.jsp">
<table>

<tr>
<td>Login Name</td>
<td><input type="text" name="username" value=""></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" value=""></td>
</tr>
<tr>
<td>Type</td>
<td>
<select name="type">
<option value="A">Admin</option>
<option value="U">User</option>
</select>
</td>
</tr>

<tr>
<td></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>


</body>

</html>

"loginmid.jsp"

<%
if(request.getParameter("username")!=null)
{
// create session
String username = request.getParameter("username");
String password = request.getParameter("password");
String type = request.getParameter("type");
String strresult="";

session.setAttribute("sessionId",username);

if(type.equals("A"))
{

strresult = "Welcome, "+ session.getAttribute("sessionId") +" is Admin " ;
}
else if(type.equals("U"))
{
strresult = "Welcome, "+ session.getAttribute("sessionId") +" is User " ;
}

out.println(strresult);


}
%>

Thanks



August 14, 2008 at 12:08 PM

Read for more information.

http://www.roseindia.net/jsp/SessionAttribute.shtml

Thanks & Regards

Amardeep









Related Tutorials/Questions & Answers:
jsp - session - JSP-Servlet
JSP - Session  How to manage session in JSP
JSP Session Object
JSP Session Object  JSP Session Object?   Session Object denotes the data associated with a specific session of user. The class or the interface name of the object session is http.HttpSession. The object session
Advertisements
Session Timeour - JSP-Servlet
Session Timeour  Hi, How to create a session timeout page in JSP? Session timeout should happen after 15 mins of idle instance. Thanks ... the following link: http://www.roseindia.net/jsp/jsp-session-parameter
Session Problem in JSP - JSP-Servlet
Session Problem in JSP  I have developed a online feedback form in JSP platform. I have created normal session in JSP page. It is running in my... then the session is not working. I have not used EJB. Please tell me how can I track session
Session removing - JSP-Servlet
Session removing  Hi, I am destroying session by using session.invalidate() in JSP but I am not able to destroy it completely can anyone help me... has been in session using session. setAttribute() but at log off I am using
session concept - JSP-Servlet
session concept  Hello friends, How can we track unexpectedly closing a window when a jsp project running with session concept. And this tracking should update the log in status in data base
session in jsp - Java Beginners
let me know how to create a session in jsp. Session for jsp with two side...   Hi friend, session is implicit object in jsp. using session oject in jsp. first u set using following methods String name
session tracking in jsp
session tracking in jsp  hi... i am creating 3 jsp pages ie. login.jsp,display.jsp,userinput.jsp.. i am able to pass the value from login.jsp to display.jsp using session set attribut ang get attribute.. but same ting
Session concept - JSP-Servlet
Session concept  Hai friends, I am doing a jsp project with session concept. If one person is not accessing his logged window for more than 10 minutes it gets automatically log out.Anybody explain me the reason
JSp session time out
JSp session time out  Consider a case where we are working on a java... for it??   If you want to make session timeout programatically, you can use... the maximum time in seconds before a session becomes invalid. Its syntax
Clearing session in jsp
Clearing session in jsp  i have developed a web appilcation using jsp and when user try to logout, session is not clearing even though i have used session.invalidate() and session.removeAttribute("username
Session Tracking JSP - JSP-Servlet
Session Tracking JSP  Respected sir/madam, I am R.Ragavendran.. I Immediately need a coding for session tracking in JSP. Actually when... information. http://www.roseindia.net/jsp/loginstatus.shtml Thanks
session maintainence - JSP-Servlet
session maintainence  if the logout link is clicked in the main page.... login application in jsp function validateForm(theForm...; } Login Application in JSP
session in jsp
session in jsp In this section you will learn about session in JSP. Here you will learn about how to use the HttpSession in JSP. session in JSP is defined... to use the session object in the JSP page. This example explains you how
set cookieless session variables in jsp
set cookieless session variables in jsp  I want to know how to set cookieless session variables in jsp, because when I run my application multiple... that . So, please tell is it possible in jsp to use cookieless session variables
session - JSP-Servlet
redirect the session  how i can redirect the session in any child window
session - JSP-Servlet
session  How to manage session for a particular user ..using session management?  Answer:If you get id as a integer from mlid field then userid is set in your session.RegardsAmar  Answer:If you get id
session maintainence - JSP-Servlet
session maintainence  how to enable a link only if the form in previous page is clucked  please show me your code
arraylist with session - JSP-Servlet
arraylist with session  hi how can an arraylist stored in session.. and also how will it access?? pls give me the details with sample code..   Hi friend, Code to solve the problem : Thanks
session management - JSP-Servlet
session management  hi friends... hope u all dng fine. i am dng... think i am not using session management properly. and also in my web.xml file i said session timeout 1min. even it is also not working.wht to do :-( i will give
JSP Session Parameter rewrite
JSP Session Parameter rewrite   ... in jsp.ADS_TO_REPLACE_1 JSP session provides methods like getCreationtime... is an example which illustrates you how to show session parameters in jsp. Here
servlet session - JSP-Servlet
the counter if new user logs on and decrement if session times out or user  Hi... on and decrement if session times out or user log offs.Thanks
session - JSP-Servlet
session  please send me an example code for session tracking using... that the Web server can't easily remember previous transactions.In session tracking.... There are four types of Session Tracking 1.Session 2.Cookies 3.Url-rewriting
session tracking - JSP-Servlet
session tracking  hi, i m working on a real estate web site....which i have to submit as final year project. im having problem regarding session... site how do i track his session activities....how to my pages will display his
Login Authentication and session in JSP - JSP-Servlet
Login Authentication and session in JSP  Hi, I am creating an small application in JSP,in which i need to check user authentication and session on each JSP page.Also how do i make logout page. Can you help me
get a session object - JSP-Servlet
get a session object  how to do in a table when i click on a radio button i should get the id value which is in the same row and store it in the session this is in jsp when in the servlet if i call a get session i have to get
Disabling Session in JSP
Disabling Session in JSP  ...; In this tutorial you will learn how to disable session creation in the JSP pages. Disabling the session in some pages will improve the performance of your JSP
Session In JSP
Session In JSP      ... of World Wide Web (WWW).    Session Management in JSP...; Cookies in JSP When cookie based session management is used, a token
session syntax for logout - JSP-Servlet
session syntax for logout  What is the syntax for writing session.../jsp/  For the security reason, every application requires login... users.No matters it devekoped using Java, Jsp or any other language!Try above
session value not get in many jsp page.
session value not get in many jsp page.  I am using servlet to set session by following code :- HttpSession session=request.getSession(false...,response); and get session value on jsp page by follwing:- (adsbygoogle
JSP Implicit object "session"
JSP IMPLICIT  OBJECT "SESSION"In this Section , we will discuss about JSP implicit object "session" with an example. Session Object represents the data associated with a user's session. The request
Session tracking in login jsp program - JSP-Interview Questions
Session tracking in login jsp program  I have using jsp technology in my project.I want to do session tracking in my login form.After logout when i press back button it should be show session is expired.Please help me. Send
session maintaining after logged in in jsp
session maintaining after logged in in jsp  Hi. I have created a login page. after the user logged in successfully if the user gives refresh the the control goes to the website home page. i want to retain in the same page
Servlet Session Tracking - JSP-Servlet
Servlet Session Tracking  Hi I have made a main page called..."); PrintWriter pw = res.getWriter(); pw.println("Test Session Attributes... == null_ { pw.println("No Session found"); } else
problem without session tracking - JSP-Servlet
problem without session tracking  i want to see the code in which no session tracking has done and that is yielding the problem without session.... For read more information : http://www.roseindia.net/jsp/ Thanks  
uninvalidateble (infinite) session - JSP-Interview Questions
with HTTPSession. Here is a client and JSP page. Every 5 seconds client requires update thruogh AJAX, so session will never expire!! So, problem is that I need... session. second - (that I need) - do not continue the session. Is anybody knows
Session expire and back button in jsp and servlet .
Session expire and back button in jsp and servlet .  Hii Sir... to invalidate the session after a certain interval of time and after clicking logout button.Means that after session expiry time and logout action no one can access
Preventing the creation of a Session in a Jsp Page
Preventing the creation of a Session in a Jsp Page          In jsp we have been provided the implicit session object. In jsp the session
session
session   explain sessioln tracking in jsp and display program
Track user's session using 'session' object in JSP
Track user's session using 'session' object in JSP This section is about tracking user identity across different JSP pages using 'session... with the help of session API. JSP provides an implicit object called session which
How to implement session variables - JSP-Servlet
How to implement session variables  Hi, I have a servlet which gets parameter from a jsp page(x). it is stored in a variable in servlet as shown below. the servlet response is another jsp page(y). I should put the value of amp
How to make session control using only JSP programming language
How to make session control using only JSP programming language  Could i do Controlling session using only JSP programming language without using anylanguage
Session Management in JSP
Session Management in JSP     ... explicitly as we do in Servlets. In Jsp the session is by default true. The session...; %>. If we don't declare it inside the jsp page then session will 
how to make session timeout programatically - JSP-Servlet
how to make session timeout programatically  hi, i have a login page with username and password. how to make session timeout for 10minutes... to make session timeout programatically, you can use the method
Remove attribute in user defined session - JSP-Servlet
Remove attribute in user defined session  Hi, How we can set remove attribute for user defined session. I am appreciating if you are sending solution as soon as possible? Thanks, Sanat Kumar
session realtime usage program simple jsp program or servlet ,which understands me importance of session
session realtime usage program simple jsp program or servlet ,which understands me importance of session  I knew importance of session theoritically like client state storage scope.,but jsp or servlet realtime simple session
The session Attribute of page Directive In JSP
The session Attribute of page Directive In JSP  ... illustration of the session attribute of the page directive in JSP... for running the JSP page on the server. If you set the value of session object false
session
session  how to implement login-logout session????   Please.../Logout.shtml http://www.roseindia.net/jsp/javascriptpagerefresh.shtml http://www.roseindia.net/jsp/loginstatus.shtml http://www.roseindia.net/struts/struts2/struts2
can pass list of n values in session and get in jsp
can pass list of n values in session and get in jsp  In dao: am... In servlet: list=userBean.selectUserBo(); HttpSession session = request.getSession(true); session.setAttribute("currentUser",list); In jsp: <
can pass list of n values in session and get in jsp
can pass list of n values in session and get in jsp  In dao: am... In servlet: list=userBean.selectUserBo(); HttpSession session = request.getSession(true); session.setAttribute("currentUser",list); In jsp: <

Ads