How to validate a session object in jsp?
Hi All,
i am facing a problem.The problem is how to validate the session object object in jsp.I have written a java script by using a defined function as setInterval and has given 5 mintues if the user is idle and will show a pop up menu before time out the session but in case of page active still this pop up menu is coming. The java script as follows.
function SetTimer(){
//How long before timeout (should be a few minutes before your server's timeout
//set timer to call function to confirm update
if(timeoutMinutes)
timerObj = setInterval("ConfirmUpdate()",60000);
function clearTimerFn(){
timerCount = 0;
clearInterval(timerObj);
//timerObj = setInterval("ConfirmUpdate()",60000);
function ConfirmUpdate(){
//Ask them to extend
if(confirm("Your session is about to expire. Press 'OK' to renew your session.")){
//load server side page if ok
var url = "ajaxSessionchecker.do?sessionvalidate=sessionvalid";
LoadXMLDoc(url);
And in jsp i am calling this js function as
<%session=request.getSession(false);
if(session.getLastAccessedTime()==60000){ %>
<script type="text/JavaScript">
clearTimerFn();
</script>
<%}else{
session.setMaxInactiveInterval(-1000);} %>
could you pls help me out?
The reason for doing this is when ever i come to this user.jsp from account.jsp with a different account number this user.jsp is not refreshed and i still
see the same old user.jsp for the previous account that i naviated before. Also please let me know if there is any other approach to acheive this taskDoes refreshing the page by pushing F5 solve the problem?
If so, then the browser is caching the page, despite your attempts to stop it.
Similar Messages
-
How to use session object in jsp
hi all
marry christmas
can anyone plz tell me how to use session obect in jsp
rachna
Message was edited by:
rachna_arora82hi rachna,
JSP has a default(implicit) session object...... use the getSession(true) method on the session object and then going u can either get or set attributes depending on the requirement
That was in general and now with the issue u have got..... what u can do is that the u can create session for every user who logs in and when he/she tries to login again then u can probably check for the existing session object in the JSP and perform the logic as required..... any clarifications plzzzzzzz let me know
Thanks n Regards
Naveen M
Message was edited by:
Novice_inJAVA
Message was edited by:
Novice_inJAVA -
How to get Request/Session objects in a Webdynpro application
Hi
I am working in Enterprise Portal 7.0.
in one of the iViews which displays a JSP page, i have set a parameter in request and session objects.
How can i get it in my Webdynpro ABAP Application?
Thanks & Regards
Abhimanyu Lhi Abhimanyu
I believe originally access to session was deliberately not made available inside WDA.
Growing security concerns due to misuse of session information and
perhaps other reasons as well.
X.509 is considered a better approach.
This may not help you in your problem.
But you may see a trend in WDA pushing more robust and client independent
approaches.
Full x.509 access should remove the need for session fiddling.
Also when developers access such session info directly, there is a possiblity
when they dont understand the technology exactly that they create a security hole.
You may know how to do safely, it is however discouraged.
Im not aware of a way to get at the session info inside the WDA framework.
Well not without a mod to the framework.
It may be possible without a mod, but I dont know the trick.
If someone has a little trick... please post.
You may need to use BSP, if your only solution requires access to the session info.
regards
Phil -
How to use a Session object in a Javascript function
I have an object that I have set in my session.
On my jsp I want to pull it out of my session and use it as a parameter for a javascript function. But I am not sure how to do that... the function call is below... I want to assign a value to ifFormat (last variable in function) But I am not sure what to use inside javascript.
<script type="text/javascript">
Calendar.setup({inputField:"f_date_dfFirstPmtDate",
button:"f_trigger_dfFirstPmtDate",
singleClick:true,
ifFormat:XXXXX});
</script>Note that javascript runs on the client side, and JSP runs on the server. JSP and the session objects are NOT available to javascript in reaction to the user.
If this function is called only when the page is first created, not when the user interacts with the page, or if you want that value to be constant with respect to the javascript, then you can do this:
<%
String someValue = (String)session.getAttribute("theAttributeName");
%>
<script type="text/javascript">
Calendar.setup({inputField:"f_date_dfFirstPmtDate",
button:"f_trigger_dfFirstPmtDate",
singleClick:true,
ifFormat:<%=someVale%>});
</script> -
How can i get session object based on session id?
I have tried searching in forum but i can't find any solution that i can get session object based on session id and i also would like to know how to check whether the session is still active? My company currently using weblogic 5.1. I really hope that some one or anyone can help. I am new in using Servlet. I hope that i can find some answer here. Thank you.
I have a need to get a Session object from a session id, so I don't think that the above should be deprecated. Here is my use case:
0. I am displaying files in a file list
1. I am downloading files.
2. I am downloading files through a Servlet
3. I am displaying the files as images in an applet
4. The applet is ImageJ, and it apparently uses a full URL to download the file.
5. I use request.getRequestURL() in the applet .jsp to get the full URL (the hostname and port)
6. My app server is OC4J and it's behind an apache server and is host aliased.
7. Thus the hostname is different between my applet .jsp and the Servlet URLs
8. Thus I have 2 different sessions
9. Thus I need to pass the session id (or some other unique identifier).
10. I could stored the unique identifier in the application object, but then I would need to clean it up
11. I cannot pass the the full path to the image due to security problems (what if someone downloads my password file?)
12. I would like this to work in a clustered environment
13. I think that WebDAV would solve my problems, since I could pass a full URL of webDAV to ImageJ for download. However, I am unsure how the security of WebDAV would work with ImageJ/URLConnection. I will have to research this feature in ImageJ. -
JSP: How do display list of objects in jsp table?
sorry that my question my confuse you, let me explain more.
in my java class, have method : public List retrieveAllVacancies(); and it returns a list of available vacancies.
on my jsp page, i want to display the vicancies in the table have 3 rows:
vacancy title | location | contract type
should i use some form of for loop or iterator to get the vacancies in the list? how does the jsp page get the list of objects?
anyone can help me? thanksi found out the actual thing i look for is how to pass the vector to the jsp page.
<table>
<%
Vacancy vacancy= new Vacancy();
Vector allVacancies = new Vector();
*//allVacancies = (java.util.Vector)request.getAttribute("allVacancies");*
if(allVacancies.size() == 0)
out.print("<br><br><br> There are no vacancies available!!");
else
%>
<tr>
<td>Vacancy Title</td>
<td>Contract Type</td>
<td>Location</td>
</tr>
<%
for (int i=0;i<allVacancies.size();i++)
vacancy = (Vacancy)allVacancies.get(i);
%>
<tr>
<td><% out.print(vacancy.getVacancyTitle());%></td>
<td><% out.print(vacancy.getContractType());%></td>
<td><% out.print(vacancy.getVacancyLocation()); %></td>
</tr>
<%
%>
</table>*//allVacancies = (java.util.Vector)request.getAttribute("allVacancies");*
if i have this line, when i open the jsp page it will gives NullPoniterException.
the following was what i found for the similar problem,
You can add the Vector to the HttpSession with_
session.setAttribute(String name, Object value)_
or to the ServletRequest with_
request.setAttribute(String name, Object value)._
In the other JSP, retrieve the value with_
session.getAttribute(String name)_
or to the ServletRequest with_
request.getAttribute(String name)._
but i tried to do in this way it didn't work. for sure i didn't do it correctly. could anybody give bit more explanation about how to pass the Vector to the jsp page?
any help would be appreciated. -
Question about app design - database + session object in JSP
hi all
i am studying this application built mostly with servlets and JSPs, and there are several questions i want to ask your guys' opinions about it.
first of all, i noticed that the application hits database to get/save data very frequently. from one page to another it would save data collected from user to the DB, and retrieve data from DB to display on the next page. it does this a lot. would this decrease the overall performance of the application, i mean a DB hit requires network traffic overhead, wouldn't it be better if all data collected from user are stored in a session object temporarily, and all the data that are displayed on those pages retrieved at the start time? and do one save process in the end. it uses Oracle DB if it makes any difference. should we try to avoid db hit as much as possible?
my next question is that is it good approach to keep information in session object? even if there is a lot of data to keep?
another question is the db connection. in a pooled environment - weblogic server, we would use JNDI in the code to get connection from the pool, we use it and close it. when we close a connection with close() method, what really happens? does this connection gets return to the pool or it is being destroyed completely.
i know this is a lot to ask, i appreciate your help very much. looking forward to seeing some feedback.No, I don't have tables of values. I have a java 1.5 enumeration, like for instance:
public enum VelocityConvention {
RELATIVISTIC,
REDSHIFT;
}and a class Velocity that contains a convention and a value like so:
public class Velocity {
public VelocityConvention getConvention() {...}
public double getValue() {...}
public void set(VelocityConvention conv, double value) {...}
}When I persist the Velocity class to the database, I want a field called convention that holds the appropriate value of the enumeration. That much is done how I explained before.
I want to have a selectOneMenu for setting the convention. Via trial and error, I found that MyFaces wasn't able to automatically convert from a string back to a proper VelocityConvention enum constant. It can, of course, convert from the enum to a string because it just calls toString(). But I need both directions for any UIInput element I use, be it a selectOne, or just a straight inputText. -
How to implement a Session Object.
Hi,
If anybody show me any example of how to implement
session object so that I can store any parameters such as user id and use it later on. And also if there is any good web site for reference about using session object.
thanksYou can use the the session.setAttribute and session.getAttribute methods.
For example let's say you would want to store a username in the session after a user has logged on:
String usrname = request.getParameter("username");
session.setAttribute("myStoredUsername", usrname);
you can then retrieve it using the get method. Remember that the entities stored inside a session object are generic objects and need to be cast to be used:
String usrname2 = (String)session.getAttribute("username");
Hope this helps
Chelman -
How to create a session by AppsLocalLogin.jsp
first, in auth.jsp we check fnd_global.user_name against "ANONYMOUS" to see whether user is logged on.
if not, we invoke AppsLocalLogin.jsp to create a session.
http://server:port/OA_HTML/AppsLocalLogin.jsp?requestUrl=report.jsp%3Fparam1%3Dyyy
the login page shows, page re-directed to report.jsp.
however fnd_global.user_name doesn't work. it still returns "ANONYMOUS".
if user logged on OA normally, then the whole thing worked. it seems fnd_global.user_name doesn't like the way we login.
how should we invoke AppsLocalLogin.jsp so it'll create a proper session?
part of report.jsp:
WebAppsContext ctx =WebRequestUtil.validateContext(request, response);
conn = ctx.getJDBCConnection();
sql = "select fnd_global.user_name from dual";
(we tried to invoke RF.jsp instead.
doesn't work because we don't know how to pass the param1 to report.jsp thru RF.jsp)This is variable what is working in my aplication
String variable;
if(user == null){
user=new String("");
}//if you don'y do this you will have null pointer exception
session.setAttribute("user",user);//put value
String name=(String)session.getAttribu("user"); //get value;
I hope this will help -
URGENT! Share session object in JSP and JServlet
Dear all,
I am new to OAS. I am now trying OAS by build a simple Shopping Cart application.
Currently, I use JSP to build user interface and Servlet to build bussiness logic. So I use JSP cartage and JServlet cartage to build the application.
However, I find that the "session object" I create in the JSP cannot be access from Servlet cartage.
Is anyone can help me to solve this problem. ( Is this implementation framework works in OAS ? )>
I am short describing the problem again,
IN JSP, MY CODE IS LIKE THIS:
HttpSession oSession=request.getSession(true);
oSession.setAttribute("batchHash",reqRows);
IN SERVLET, MY CODE IS LIKE THIS:
HttpSession oSession=req.getSession(true);
tblSession = (Hashtable)
oSession.getAttribute("batchHash");
System.out.println("IsNew ="+oSession.isNew());
System.out.println("Object="+prmSSO);
If I deploy this in TOMCAT, my output is like this:
IsNew =false
Object=Hashtable@982fc1
If I deploy this in WEBLOGIC 6.1, my output is like
this:
IsNew =true
Object=null
Why is this?
Why the "oSession.isNew()" returns "false" in tomcat
and "true" in weblogic ?
Please help....Your only problem is using
HttpSession oSession=req.getSession(true);instead of
HttpSession oSession=req.getSession(false);in your servlet! getSession(true) - forces to allocate new session,
so it's absolutely clear why your Hashtable is absent in
a newly created session!!
Paul -
How to display List of objects in jsp?
Hi,
I have a list containing Collection of bean objects.
Now I want to display the values in the list of objects in a jsp using JSTL.
Any body help me how to retrieve the bean objects from the List and how can i display that values in the jsp.
Advanced Thanks,
MahendraHave you tried to use <:forEach></c:forEach> tag available in jstl?
-
How to Create a Session variable in JSP?
How to create a session variable and add attributes to it?
For example i want to create a session variable called "name" and add value "user" to it? if i try to do it with setAttribute(), it is giving error as both is of type string? how to do it? kindly help meThis is variable what is working in my aplication
String variable;
if(user == null){
user=new String("");
}//if you don'y do this you will have null pointer exception
session.setAttribute("user",user);//put value
String name=(String)session.getAttribu("user"); //get value;
I hope this will help -
How to obtain a session object from session id
Hi all,
let say that I have a list of session ids, and I want by scheduald task to check whether the session is alive\active.
I saw that the HttpSessionContext was deprecated. (see: http://javasolution.blogspot.com/2007/08/getting-session-object-using-session-id.html)
Is there any other way to check if the session is alive?Do it the other way: let the session itself notify that it is not alive anymore.
Implement a HttpSessionListener which adds the session to list/set/map on create and removes the session from it on destroy, register it in the web.xml and run it. -
How to use the ViewRowImpl objects in JSP?
Is there anyway for me to use the ViewRowImpl objects in the JSP (so I could call the set<attribute> methods and get<attribute> methods to retrieve the attributes? Right now I am retrieving all the information I need in the application tier from the database, marshal them myself, and then return the marshaled data back to the JSP side in the presentation tier, then demarshal the data, and finally interpret the demarshaled data. I did this because I want to return everything in one single remote method call, and I know this is really ugly, but I do not know of any other way for me to retrieve all information needed by a JSP page in one single method call. Any suggestions?
I've done this in servlets.
I created an application module (with an ic.lookup() call, see the documentation) and then used the appModule to create my view.
Once you've got that you can iterate through rows and use the accessor methods.
You might need a wrapper method to get the ViewObjectImpl in your jsp... -
How to validate the string object for alphabet input
Hi,
I want to check for alphabet (a-z,A-Z), in String object. I need to check the object, whether its contain numerals or special character, in that case, I want to throw an error stating that "value is not valid". It should accept only the a-z or A-Z.
how to do this.
Thanks in advance
Karthi> I want to check for alphabet (a-z,A-Z), in String
object. I need to check the object, whether its
contain numerals or special character, in that case,
I want to throw an error stating that "value is not
valid". It should accept only the a-z or A-Z.
how to do this.
As Rene suggested, you can do this using the Pattern class:
http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html
You can do it also by looping through your String and check with String's charAt(index) method (which returns a char) to see if every char from the String is >= A AND <= z.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html
Good luck.
Maybe you are looking for
-
Revaluate data record at the time of loading from flat file or BI Cube
Hello Friends, I want to revaluate a data record at time of loading using Transformation or Conversion File, based on some condition. Like, I have a rule to identify that a record is supposed to be multiplied by -1 or not. For example, *if (ID(1:5) =
-
IPhone no longer works after iOS 5.0.1 update
My iPhone 4 no longer recognizes its SIM card after updating from iOS 5.0 to 5.0.1. I followed the instructions in the article on the official Apple support site. Removing and reinserting the SIM card did not help, so I used iTunes to reset the iPhon
-
Add new field infotype "z" in logical database selection screen pnp
Can add new field infotype "z" in logical database selection screen pnp I could explain how to realize Thanks
-
I recently bought an iMac and love it. Only proplem I have is I keep getting an error message "the disk was not ejected properly" Everything is backing up fine on my Seagate 2TB external USB drive. Each time there is access on the seagate and it stop
-
what are the impacts of disabling/deleting default guest user in BO XI R2 SP1 in a Unix solaris environment.