Finding Previously visited page in APEXOracle Application Express is packaged with Oracle Database. It runs under database environment. In APEX, It is possible to find out previously visited page. APEX stores data related to application in tables. This is known as metadata. i.e. Data about data. APEX metadata consist of several tables. There are several views created on these tables. These views can be accessed by application developer (Note that this views can be accessed in readonly mode. But this is good enough for us). apex_workspace_activity_log is one of such view.
Have a look at this SQL Query. It can be executed in your apex page.
from (select page_id
where application_id = :app_id and apex_user = :app_user and apex_session_id = :app_session and page_id <> :app_page_id order by seconds_ago)
where rownum = 1
This query gives you last visited page. You need to use "page_id <> :app_page", otherwise it will give you the most recently used page. And most recently page would be the page where you are executing your query.
Generally you will be expecting previously visited main page. sometimes, there may be popup pages available on parent page. If user visits popup page, you would not get expacted result. In such circumstances, you can use this clause
where page_id not in (list of popup pages).
If you can find out most possible parent page then you can use this clause.
where page_id in (list most possible parent page).
This clause will be most appropriate if you know possible parent pages.