User.jsp
I', changing the ifs web interface. In order to make the new jsp file to take work effectively, i'm delete all the files under the oracle_home\ifs\ifsjsps\_ifs\_webui\_jsps. After that, it not allow me to create a new user. An error message coming out saying that "500 internal server error. Java Server Page Translation Error - Class oracle.ifs.clients.admintool.common.IfsRepositoryData not found in type declaration. out.print(oracle.ifs.clients.admintool.common.IfsRepositoryData.DEFAULT_MAIL_FOLDER);
^
D:\Oracle\Ora81\ifs\ifsjsps\_ifs\_webui\_jsps\_user.java:583: Class oracle.ifs.clients.admintool.common.IfsRepositoryData not found in void _jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse).
out.print(oracle.ifs.clients.admintool.common.IfsRepositoryData.DEFAULT_MAIL_FOLDER);
can anyone tell me why??
Thank you.
Oracle iFS 1.0 and 1.1 do not support modifying the out-of-the-box Web UI.
With these releases, you can build a full Web user interface using JSPs, or plug in a JSP for rendering specific types of documents (by Content Type).
Please refer to the Oracle iFS Developer's Guide for instructions on building custom Web user interfaces.
Similar Messages
-
How to handle an update of the same record from two different user JSP
how do you handle an update of the same record from two different users in JSP... if one person updates the record from one drop downs should be updated as well.. is the possible.
I'm not sure whether I understand your question. If one user changes a record then you would like other users to see those changes. Normally those changes will be visible to other users when they refresh their browser, after the first user has committed changes to the record. I you want to be sure that the same row isn't updated at the same time by to different user, you need to configure some locking (pessimistic locking) - this depends of what technology you use. In EJB3 pessimistic locking is performed by adding a version to every entity object. If you are using ADF, the framework is able to handle either pessimistic or even optimistic locking.
If you want the changed row to be updated in other users browsers without any user interaction by these users, you should take a look at Reverse Ajax (ex. DWR http://ajaxian.com/archives/reverse-ajax-with-dwr) - or Ajax in general. But you will never get a realtime solution, where changes is visible in other users browsers right after each record update. -
Reloading JSP for a specific role's users
Hi all,
We have a web application using JSPs.
Our application has users and roles. A user is associated to a role. These are defined in 2 tables:
create table role
( id int not null primary key,
name varchar(50) not null )
create table user
( user_name varchar(50) not null primary key,
user_password varchar(50) not null,
role_id int not null foreign key references role(id) )
For example:
insert into role values (1, 'HR')
insert into user values ('michaelK', 'password', 1)
insert into role values (2, 'Payroll')
insert into user values ('babarA', 'honest', 2)We have 2 tables where we store all our application's web pages and buttons on each page:
create table web_page
( id int not null primary key,
name varchar(50) not null )
create table web_page_button
( id int not null primary key,
name varchar(50) not null,
web_page_id int not null foreign key references web_page(id) )
For example:
insert into web_page values (1, 'Personal_Info') // "Personal Info" Screen has 2 buttons: update and cancel
insert into web_page_button (25, 'update', 1)
insert into web_page_button (26, 'cancel', 1)We have a requirement that the administrator want the facility to enable/disable buttons on each web page for a specific role. So we have created a table where we define enable flag for each button of a web page w.r.t a Role:
create table role_web_page_button
( id int not null primary key,
role_id int not null foreign key references role(id),
web_page_button_id int not null foreign key references web_page_button(id),
enable_flag int not null )So if the administrator say that for users belonging to "Payroll" role the "Update" button on "Personal Info" Screen will be disabled.
insert into role_web_page_button values (100, 2, 25, 0)The user first go to login.jsp and provide login information. If successful we store his user_name and role_id in the session as an attribute. We then redirect the user to index.jsp. In this jsp we have a header.jsp on top. This JSP remains there on all web pages user visit.
In that JSP we generate one Javascript function getButtonEnableFlags(). This function defines each button's enable flag of each screen for the user's role_id. So when a user of "Payroll" role logins then this is generated:
function getButtonEnableFlags()
var buttonEnableFlags = new Object();
buttonEnableFlags["Personal_Info::update"] = "0";
return buttonEnableFlags;
}We also have a javascript function which tells us the enable flag's value for a button of a screen.
function getButtonEnableFlag(webpageName, buttonName)
var buttonEnableFlags = getButtonEnableFlags();
var keyName = webpageName + "::" + buttonName;
return buttonEnableFlags[keyName];
}Each Web Page after loading calls a common javascript function setupButtons(webpageName). This function receives a webpage name, picks all buttons on the form of that web page, then call getButtonEnableFlag(webpageName, buttonName) to get enable flag for each button and then set it.
This solution is working fast and perfect. The javascript function getButtonEnableFlags() is generated once when user logins so each web page does not have to call the server to figure out enable flag for their buttons.
I have created a maintenance screen for the Administrator which provides the facility to enable/disable buttons on each web page for a specific role. This screen updates the role_web_page_button table.
Problem is if the Administrator makes any changes for a Role how can I reflect that change on the user's of that role which are already login in the system? For example suppose 2 users of "Payroll" role are login in the system and for "Peson_Info" web page the "update" button is disabled. Now administrator changes the "update" button of "Personal_Info" web page to enable for "Payroll" role through the maintenance screen. How can I reload the header.jsp on only those 2 user's computer?
ThanksI suppose you can use AJAX to change the end-users JSP page that is displayed on his browser as he is vieiwing it.
However, I suggest against changing permissions on a JSP page while the user is using it (I believe most programmers do not do that). If I was an end-user with a JSP page displayed and I suddenly see the 'update' button disapear, I would be very upset.I suggest waiting for the user to close his session (and not simpily navigate to another page within the session, but actually ending the session by either calling up another web site or closing the browser) and when he next logs into the applcation again, the button is gone. If the administrator does take away a permission such as an 'update' button, do you really need to deny permission to everyone right then? I think you can wait for users to log off.
An alternative is to create a batch job that when the admin removes permission, the batch job runs at midnight to actually change the permission in the database. Since few people are logged on at midnight, few people will see the change while they are working.
Another possiblity is when they click the update button, don't do an actual update to the database. Instead, redraw the page with the update button disabled (not removed) and add a note on the JSP page that the administrator has just removed permission for all users to update at this time. -
How to load the same jsp page and set user id to 0 when checkbox is selecte
I hope this question isn't too amateurish to answer, but it is something that has been troubling me.
I have a jsp page page that display information about a user and has the userID passed in the link. So something like user.jsp?userID=12 for example.
On the same page I have a form with a checkbox, and a submit button, the html code is as follows:
<form name="form1" method="get" action="user.jsp">
<p><input name="userID" id="userID" type="checkbox" value="0"></p>
<p><input name="Submit" type="submit" value="Submit"></p>
</form> What I want to do is, if a user ticks the checkbox and presses Submit, I want to load the same page again, but
set the userID to zero and so the top url has the following: user.jsp?userID=0
How can I achieve this.
Thanks for all the help
Zubactually I need a check code which on submit checks if the checkbox is ticked then set the value of UserID to zero. so when I press submit and before the page loads to simply does a check if its ticked? I can write the if statment but I do not know what how to check if the checkbox is ticked and were to include the code
-
Need help on Modifying Jsp Code to establish relationships in iStore.
I am currently working on iStore an internet enabled product
from Oracle.
In iStore one can establish relationships between products like
cross sell , complimentary, substitute, conflict etc. However at
the moment only one relationship works i.e: Related. This is
because this is a bug in iStore. Only the relationship Related
is defined in the jsp. We have been asked to modify the jsp
ibeCCtdItemDetail.jsp
Please find pasted below the jsp which only had the arrays for
related i.e: relitems and service i.e service have added the
array complimentary to establish such a relationship and pasted
the relitems code once again and changed relitems to
complimentary. I am stuck up on this since the past 2 weeks i
would appreciate if anybody could help.
<%@include file="jtfincl.jsp" %>
<!-- $Header: ibeCCtdItemDetail.jsp 115.24 2001/06/16 15:21:05
pkm ship $ -->
<%--
=================================================================
========
| Copyright (c)2000 Oracle Corporation, Redwood Shores, CA
| All rights reserved.
+================================================================
===========
|
| FILE
| ibeCCtdItemDetail.jsp - Item Detail display
|
| DESCRIPTION
| Displays Item Detail page. Item's description, long
description, large
| image, flexfields, available services, and related items
are displayed.
| The list price and best price (selling price) for each of
the Item's
| available units of measure is displayed. Displays Add to
Cart,
| Express Checkout, Configure buttons (if appropriate).
|
| PARAMETERS (SOURCE)
| party Id IN (RequestCtx) - user's party
id
| account Id IN (RequestCtx) - user's
account id
| currency code IN (RequestCtx) - currency code
| item IN (URL) - Item ID
| section IN (URL) - section ID of
section we are
| coming from
(optional)
| item IN (pageContext) - Item ID
| section IN (pageContext) - Section ID
| qty IN (pageContext) - Quantity
entered by user
| uom IN (pageContext) - UOM selected
by user
| errorMsg IN (pageContext) - error message
from buy
| routing page
| * pageContext attributes for "item" and "section" are used
when the URL
| does not contain valid values for "item" and "section"
(such as when an
| error occurred in the buy routing page and the request is
forwarded
| back to this page)
|
| oneclick_obj OUT (pageContext) - OneClick
object containing
| user's
Express Checkout
| preferences
| postingID OUT (pageContext) - Integer
posting Id, for
| iMarketing
integration
| itemIDs OUT (pageContext) - int[] itemIDs
on the page
| (for use by
postings)
| numRequested OUT (pageContext) - Integer
number of postings,
| for
iMarketing integration
| random OUT (pageContext) - Boolean
whether to randomize
| posting
retrieved, for
| iMarketing
integration
| type OUT (HTML form) - "single" (1
item)
| item OUT (HTML form) - Item ID
| refpage OUT (HTML form) -
"ibeCCtdItemDetail.jsp" plus any
| parameters
needed to return
| to this page
in case of error.
| uom OUT (HTML form) - UOM code
selected by user
| qty OUT (HTML form) - quantity
entered by user
| Add to Cart.x OUT (HTML form) - user clicks
Add to Cart
| 1-Click.x OUT (HTML form) - user clicks
Express Checkout
| Configure.x OUT (HTML form) - user clicks
Configure
|
| OBJECTS REFERENCED
| oracle.apps.ibe.catalog.Item
| oracle.apps.ibe.order.OneClick
|
| APIs REFERENCED
| Item.getItemID() - get Item ID
| Item.getDescription() - get item description
| Item.getLongDescription() - get item long description
| Item.isConfigurable() - whether item has
configuration UI set up
| Item.getFlexfields() - get Item flexfield
prompts and values
| Item.getRelatedItems() - get related items and
service items
| Item.getMediaFileName() - get media based on
display context
| OneClick.loadSettingFrDB() - load Express Checkout
settings for
| current user
|
| JSPs REFERENCED
| ibeCCtpPostingI.jsp - set iMarketing
parameters (include)
| ibeCCtpSetItem.jsp - retreive and set item
information (include)
| ibeCCtpItmDspRte.jsp - Item display routing
page (link)
| ibeCCtpBuyRoute.jsp - Buy routing
page (form POST)
| ibeCCtdSctPath.jsp - Path Traversed
Display (include)
| ibeCXpdShowTag.jsp - Express Checkout Tag
Area (include)
| ibapstng.jsp - iMarketing integration
page (include)
|
| ADDITIONAL NOTES
| iMarketing posting ID can be changed by editing file
ibeCCtpPostingI.jsp
|
| HISTORY
| 08/01/2000 auyu Created.
| 04/09/2001 auyu Added compile-time include for retrieving
item
| information
|
+================================================================
=======--%>
<%@page import="oracle.apps.ibe.order.*" %>
<%@page import="oracle.apps.ibe.catalog.*" %>
<%@page import="oracle.apps.ibe.store.*" %>
<%@page import="oracle.apps.jtf.displaymanager.*" %>
<%@page import="oracle.apps.jtf.base.Logger" %>
<%@page import="oracle.apps.jtf.minisites.*" %>
<%@include file="ibeCZzpHeader.jsp" %>
<%@page import="oracle.jdbc.driver.*" %>
<%@page import="java.sql.*" %>
<%-- declaration --%>
<%!
/* Retrieve parent section ids for a given item.
* int itemId - Item whose parent section ids will be retrieved
int getParentSectionId(int itemId)
int parentSectionId = -1;
Connection conn = null;
OraclePreparedStatement stmt = null;
ResultSet rs = null;
try {
BigDecimal minisiteId = RequestCtx.getMinisiteId();
conn = TransactionScope.getConnection();
StringBuffer sql = new StringBuffer(400);
sql.append("select jdsi.section_id ");
sql.append("from jtf_dsp_section_items jdsi, ");
sql.append("jtf_dsp_msite_sct_items jdmsi ");
sql.append("where jdsi.inventory_item_id = ? ");
sql.append("and jdsi.section_item_id =
jdmsi.section_item_id ");
sql.append("and jdmsi.mini_site_id = ? ");
sql.append("and nvl(jdsi.start_date_active, sysdate) <=
sysdate ");
sql.append("and nvl(jdsi.end_date_active, sysdate) >=
sysdate ");
sql.append("and nvl(jdmsi.start_date_active, sysdate) <=
sysdate ");
sql.append("and nvl(jdmsi.end_date_active, sysdate) >=
sysdate");
stmt = (OraclePreparedStatement)conn.prepareStatement
(sql.toString());
stmt.setInt(1, itemId);
stmt.setInt(2, minisiteId.intValue());
stmt.defineColumnType(1, Types.INTEGER);
rs = stmt.executeQuery();
if (rs.next())
parentSectionId = rs.getInt(1);
} catch (Exception e1) {
parentSectionId = -1;
IBEUtil.log("ibeCCtdItemDetail.jsp",
"Caught exception while retrieving parent
section id");
IBEUtil.log("ibeCCtdItemDetail.jsp", e1.getMessage());
} finally
try { if (rs != null) rs.close(); } catch (Exception e2) {}
try { if (stmt != null) stmt.close(); } catch (Exception
e2) {}
try {
if (conn != null) TransactionScope.releaseConnection
(conn);
} catch (Exception e2) {}
return parentSectionId;
%>
<%-- end declaration --%>
<%@include file="ibeCCtpSetItem.jsp"%>
<%
The compile-time inclusion of ibeCCtpSetItem.jsp will declare
and set
the following variables:
boolean bItemLoaded - whether section was
loaded
Item lItem - Item
boolean bItemCanBeOrdered - whether item can be
ordered
String[] uomCodes - Item's UOM Codes
Vector itemSellPriceDisplayVec - vector containing
item's selling
prices in formatted
strings
Vector itemListPriceDisplayVec - vector containing
item's list
prices in formatted
strings
int nPriceDefined - number of prices
defined for the item
Perform the following actions:
Set "itemIds" in the PageContext.REQUEST_SCOPE
Set "item" in PageContext.REQUEST_SCOPE
Set "section" in PageContext.REQUEST_SCOPE
MessageManagerInter lMsgMgr =
Architecture.getMessageManagerInstance();
pageContext.setAttribute("_pageTitle",
lMsgMgr.getMessage
("IBE_PRMT_CT_PRODUCT_DETAILS"),
PageContext.REQUEST_SCOPE);
%>
<%@ include file="ibeCCtpPostingI.jsp" %>
<%@ include file="ibeCZzdTop.jsp" %>
<%@ include file="ibeCZzdMenu.jsp" %>
<%
if (bItemLoaded)
OneClick lOneClickObj;
String xprTagArea = "", confirmXpr = "";
String lBuyRoutePage;
String lSectionPathPage = "";
int sectid = 0;
Item[] services = new Item[0];
Item[] relItems = new Item[0];
Item[] complimentary = new Item[0];
ItemFlexfield[] itemFlexfields = new ItemFlexfield[0];
String lItemImage = "", lItemAddtlInfoFile = "";
StringBuffer lRef = new StringBuffer("ibeCCtdItemDetail.jsp?
item=");
String qty = "", userSelUOM = "";
String errorMsg = "";
//--------------- load express checkout preferences ---------
if (IBEUtil.useFeature("IBE_USE_ONE_CLICK"))
xprTagArea = DisplayManager.getTemplate
("STORE_XPR_TAG_AREA").getFileName();
if (xprTagArea == null)
xprTagArea = "";
confirmXpr = lMsgMgr.getMessage("IBE_PRMT_EXPR_CONFIRM");
if (RequestCtx.userIsLoggedIn()) {
//initialize OneClick if user is logged in
BigDecimal partyId = RequestCtx.getPartyId();
BigDecimal accountId = RequestCtx.getAccountId();
lOneClickObj = new OneClick();
lOneClickObj.loadSettingsFrDB(partyId, accountId);
} // end user express checkout
//------------ set "section", lSectionPathPage --------------
String lSectionId = IBEUtil.nonNull(request.getParameter
("section"));
if (lSectionId.equals(""))
lSectionId =
IBEUtil.nonNull((String)pageContext.getAttribute
("section", PageContext.REQUEST_SCOPE));
if(IBEUtil.useFeature("IBE_USE_SECTION_PATH"))
lSectionPathPage = DisplayManager.getTemplate
("STORE_CTLG_SCT_PATH").getFileName();
try {
sectid = Integer.parseInt(lSectionId);
pageContext.setAttribute("section", String.valueOf
(sectid), PageContext.REQUEST_SCOPE);
} catch (NumberFormatException e) { }
if(lSectionPathPage == null)
lSectionPathPage = "";
lBuyRoutePage = DisplayManager.getTemplate
("STORE_CTLG_BUY_PROCESS_ROUTE").getFileName();
/* if error and forwarded back to this page, get values
selected by user */
qty = IBEUtil.nonNull((String)pageContext.getAttribute
("qty", PageContext.REQUEST_SCOPE));
if (qty.equals(""))
qty = "1";
userSelUOM = IBEUtil.nonNull((String)pageContext.getAttribute
("uom", PageContext.REQUEST_SCOPE));
errorMsg = IBEUtil.nonNull((String) pageContext.getAttribute
("errorMsg", PageContext.REQUEST_SCOPE));
//set ref for returning to this page in case of error
lRef.append(lItem.getItemID());
if (sectid > 0)
lRef.append("§ion=");
lRef.append(sectid);
/* Get Bin Open and Bin Close Images */
String binOpenImg = "", binCloseImg = "";
try {
Media binOpenMedia = DisplayManager.getMedia
("STORE_BIN_OPEN_IMAGE", true);
if (binOpenMedia != null)
binOpenImg = binOpenMedia.getFileName();
} catch (MediaNotFoundException mnfe) {}
if (binOpenImg == null)
binOpenImg = "";
try {
Media binCloseMedia = DisplayManager.getMedia
("STORE_BIN_CLOSE_IMAGE", true);
if (binCloseMedia != null)
binCloseImg = binCloseMedia.getFileName();
} catch (MediaNotFoundException mnfe) {}
if (binCloseImg == null)
binCloseImg = "";
/* Get images, additional info, flexfields, related items,
service items */
lItemImage = lItem.getMediaFileName
("STORE_PRODUCT_LARGE_IMAGE");
lItemAddtlInfoFile = lItem.getMediaFileName
("STORE_PRODUCT_ADDTL_INFO");
// check for defaulting
String defaultFromSection = "Y";
if ("Y".equals(defaultFromSection))
if (lItemImage == null || lItemAddtlInfoFile == null)
try {
int parentSectionId = getParentSectionId
(lItem.getItemID());
Section parentSection = Section.load(parentSectionId);
if (lItemImage == null)
lItemImage = parentSection.getMediaFileName
("STORE_SECTION_SMALL_IMAGE");
if (lItemAddtlInfoFile == null)
lItemAddtlInfoFile = parentSection.getMediaFileName
("STORE_SECTION_ADDTL_INFO");
} catch (Exception e) {}
itemFlexfields = lItem.getFlexfields();
try {
services = lItem.getRelatedItems("SERVICE");
} catch (ItemNotFoundException e) {}
try {
relItems = lItem.getRelatedItems("RELATED");
} catch (ItemNotFoundException e) {}
try {
complimentary = lItem.getRelatedItems("COMPLIMENTARY");
} catch (ItemNotFoundException e) {}
%>
<!-- body section -----------------------------------------------
------------->
<table border="0" width="100%">
<%
if (IBEUtil.showPosting()) {
%>
<!--------- iMarketing integration ----------------->
<tr><td colspan="4" align="center">
<% try {
%>
<jsp:include page="ibapstng.jsp" flush="true" />
<% } catch (Throwable e) {
IBEUtil.log("ibeCCtdItemDetail.jsp", "iMarketing error",
Logger.ERROR);
%>
</td></tr>
<% } //end iMarketing installed
%>
<tr><td> </td>
<%
if(!lSectionPathPage.equals(""))
%>
<td colspan="4" class="smallLink">
<jsp:include page="<%=lSectionPathPage%>" flush="true" />
</td>
<% }
%>
</tr>
<tr><td valign="top"> </td>
<!-- center column ------------------------------------------
------------->
<td valign="top" width="70%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="3">
<span class="pageTitle"><%=lItem.getDescription()%
</span></td></tr>
<tr>
<% if (lItemImage != null) {
%>
<td valign="TOP"><img src="<%=lItemImage%>"></td>
<td valign="TOP" colspan="2"><%
=lItem.getLongDescription()%></td>
<% } else {
%>
<td valign="TOP" colspan="3"><%
=lItem.getLongDescription()%></td>
<% }
%>
</tr>
<% if (lItemAddtlInfoFile != null) {
%>
<tr><td colspan="3"><br>
<jsp:include page="<%=lItemAddtlInfoFile%>"
flush="true" />
</td></tr>
<% }
%>
<tr><td colspan="3"><br></td></tr>
<%
for (int i=0; i < itemFlexfields.length; i++)
String prompt = itemFlexfields.getPrompt();
String value = itemFlexfields[i].getValue();
if (value != null && !value.equals(""))
%>
<tr>
<td align="LEFT" width="20%">
<span class="sectionHeader2"><%=prompt%
</span></td>
<td align="LEFT" colspan="2" width="80%"><%=value%
</td></tr>
<% }
if (services.length > 0)
%>
<tr><td colspan="3"><br></td></tr>
<tr><td align="RIGHT" class="sectionHeader1" width="20%">
<%=lMsgMgr.getMessage("IBE_PRMT_CT_WARRANTIES")%>
</td>
<td colspan="2" align="left" class="sectionHeaderBlack"
width="80%"><hr>
</td></tr>
<%
for(int i=0; i < services.length; i++)
%>
<tr>
<td valign="TOP" class="sectionHeaderBlack"
width="20%"> </td>
<td align="left" colspan="2" valign="TOP" width="80%">
<span class="sectionHeaderBlack">
<A HREF="<%= DisplayManager.getURL
(STORE_CTLG_ITM_ROUTE", "item=" + services[i.getItemID()) %>">
<%=services.getDescription()%></A>
</span>
<%=services[i].getLongDescription()%>
</td>
</tr>
<tr>
<td colspan="3" class="sectionHeaderBlack"> </td>
</tr>
<% } //end loop through services
} // end if services.length > 0
if (relItems.length > 0) {
%>
<tr><td colspan="3"><br></td></tr>
<tr>
<td align="RIGHT" class="sectionHeader1" width="20%">
<%=lMsgMgr.getMessage("IBE_PRMT_CT_REL_PRODUCTS")%>
</td>
<td align="left" colspan="2" class="sectionHeaderBlack"
width="80%"><hr></td>
</tr>
<%
for(int i=0; i < relItems.length; i++)
%>
<tr>
<td valign="TOP" class="sectionHeaderBlack"
width="20%"> </td>
<td colspan="2" align="left" valign="TOP"
width="80%">
<span class="sectionHeaderBlack">
<A HREF="<%= DisplayManager.getURL
("STORE_CTLG_ITM_ROUTE", "item=" + relItems[i].getItemID()) %>">
<%=relItems[i].getDescription()%></A>
</span>
<%=relItems[i].getLongDescription()%>
</td>
</tr>
<tr>
<td colspan="3" align="RIGHT"
class="sectionHeaderBlack"> </td>
</tr>
<% } // end loop through related items
} // end if relItems.length > 0
%>
</table>
</td>
<%if (complimentary.length > 0) {
%>
<tr><td colspan="3"><br></td></tr>
<tr>
<td align="RIGHT" class="sectionHeader1" width="20%">
<%=lMsgMgr.getMessage("IBE_PRMT_CT_REL_PRODUCTS")%>
</td>
<td align="left" colspan="2" class="sectionHeaderBlack"
width="80%"><hr></td>
</tr>
<%
for(int i=0; i < complimentary.length; i++)
%>
<tr>
<td valign="TOP" class="sectionHeaderBlack"
width="20%"> </td>
<td colspan="2" align="left" valign="TOP"
width="80%">
<span class="sectionHeaderBlack">
<A HREF="<%= DisplayManager.getURL
("STORE_CTLG_ITM_ROUTE", "item=" + complimentary[i].getItemID())
%>">
<%=complimentary[i].getDescription()%></A>
</span>
<%=complimentary[i].getLongDescription()%>
</td>
</tr>
<tr>
<td colspan="3" align="RIGHT"
class="sectionHeaderBlack"> </td>
</tr>
<% } // end loop through related items
} // end if complimentary.length > 0
%>
</table>
</td>
<!-- right column -------------------------------------------
------------->
<td valign="top" width="20%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<% if (! binOpenImg.equals("")) {
%>
<td><img src="<%=binOpenImg%>"></td>
<% }
%>
<td nowrap class="binHeaderCell" width="100%">
<%
if (!lItem.isConfigurable()) {
%>
<%=lMsgMgr.getMessage("IBE_PRMT_CT_2_WAYS_TO_SHOP")%>
<% } else {
%>
<%=lMsgMgr.getMessage("IBE_PRMT_CT_CONFIG_PRODUCT")%>
<% }
%>
</td>
<% if (! binCloseImg.equals("")) {
%>
<td><img src="<%=binCloseImg%>"></td>
<% }
%>
</tr>
</table>
</td></tr>
<tr><td class="binColumnHeaderCell">
<table border="0" cellspacing="1" width="100%">
<tr><td class="binContentCell" align="CENTER">
<% /////////////////////////////// error
messages //////////////////////////////
if (!errorMsg.equals("")) {
%>
<table><tr><td align="center" class="errorMessage">
<%=errorMsg%>
</td></tr></table>
<% }
/////////////////////////////// display
form //////////////////////////////////%>
<!--Javascript for express checkout confirmation-->
<script language="JavaScript">
function get_confirmation(form)
if (confirm("<%=confirmXpr%>" ) ) {
form.tmpx.name = '1-Click.x';
form.tmpy.name = '1-Click.y';
form.submit();
return true;
else
return false;
</script>
<form method=POST action="<%=lBuyRoutePage%>">
<input type=hidden name="type" value="single">
<input type=hidden name="item" value="<%=lItem.getItemID()%
"><input type=hidden name="refpage" value="<%=lRef.toString
()%>">
<INPUT TYPE="HIDDEN" NAME="tmpx" VALUE="100">
<INPUT TYPE="HIDDEN" NAME="tmpy" VALUE="100">
<%= RequestCtx.getSessionInfoAsHiddenParam() %>
<%
if ( ! lItem.isConfigurable())
{ // display prices
%>
<table>
<tr><td align ="left" nowrap>
<span class="sectionHeaderBlack">
<%=lMsgMgr.getMessage("IBE_PRMT_CT_LIST_PRICE_COLON")%>
</span>
</td>
<%
for (int i=0; i < uomCodes.length && i <
itemListPriceDisplayVec.size(); i++)
if (uomCodes[i] != null && uomCodes[i].equals
(lItem.getPrimaryUOMCode()))
if (itemListPriceDisplayVec.elementAt(i) != null &&
!itemListPriceDisplayVec.elementAt(i).equals(""))
%>
<td align="right">
<%=itemListPriceDisplayVec.elementAt(i)%
<%=lItem.getPrimaryUOM()%></td>
<% } else {
%>
<td> </td>
<% }
break;
} // end primary uomcode
} // end loop through uoms and list price
%>
</tr>
<tr><td align="left" nowrap>
<span class="sectionHeaderBlack">
<%=lMsgMgr.getMessage("IBE_PRMT_CT_YOUR_PRICE_COLON")%>
</span>
</td>
<td>
<% // display selling price for each uom
if (nPriceDefined > 1) {
//prices defined for multiple UOMs for the item
%>
<select name = "uom">
<%
//--------- loop through uoms and prices ------------------
for (int i=0; i < itemSellPriceDisplayVec.size() && i <
uomCodes.length; i++)
if (itemSellPriceDisplayVec.elementAt(i) != null &&
!itemSellPriceDisplayVec.elementAt(i).equals(""))
boolean bSelectUom = false;
if (uomCodes[i] != null && uomCodes[i].equals
(lItem.getPrimaryUOMCode()))
bSelectUom = true;
if (bSelectUom)
%>
<option value="<%=uomCodes[i]%>" SELECTED>
<% } else {
%>
<option value="<%=uomCodes[i]%>">
<% }
%>
<%=itemSellPriceDisplayVec.elementAt(i)%
<%=IBEUtil.nonNull(lItem.getUOM(uomCodes))%
<%
} // end current uom has price
} //end loop i through uoms and prices
%>
</select>
<% //end more than 1 UOM with price defined for the item
} else {
if (nPriceDefined == 0) { //multiple UOMs, none with
price defined
%>
<input type=hidden name="uom" value="<%
=lItem.getPrimaryUOMCode()%>">
<% } else { // 1 UOM with price defined
String formatSellPrice = "";
String uomWithPrice = "";
for (int i=0; i < uomCodes.length && i <
itemSellPriceDisplayVec.size(); i++)
if (itemSellPriceDisplayVec.elementAt(i) != null &&
!itemSellPriceDisplayVec.elementAt(i).equals(""))
formatSellPrice = (String)
itemSellPriceDisplayVec.elementAt(i);
uomWithPrice = uomCodes;
break;
%>
<input type=hidden name="uom" value="<%=uomWithPrice%>">
<%=formatSellPrice%> <%=IBEUtil.nonNull
(lItem.getUOM(uomWithPrice))%>
<% } //end 1 UOM with price defined
} // end display selling prices
%>
</td></tr></table> <%-- end table for the price --%>
<% } // end non-configurable item
if (bItemCanBeOrdered)
// show quantity and buttons only if item can be ordered
%>
<p><%=lMsgMgr.getMessage("IBE_PRMT_CT_QUANTITY")%>
<input type="TEXT" name="qty" size="3" maxlength="20"
value="<%=qty%>">
</p>
<% if (lItem.isConfigurable()) {
%>
<p>
<input type=hidden name="uom" value="<%
=lItem.getPrimaryUOMCode()%>">
<input type=submit name="Configure.x"
value="<%=lMsgMgr.getMessage("IBE_PRMT_CT_CONFIGURE")%
"></p>
<% } else {
%>
<p>
<input type=submit name="Add to Cart.x"
value="<%=lMsgMgr.getMessage
("IBE_PRMT_ADD_TO_CART_PRMT_G")%>">
</p>
<%
if (!xprTagArea.equals(""))
%>
<p><%=lMsgMgr.getMessage("IBE_PRMT_CT_OR")%></p>
<p><jsp:include page="<%=xprTagArea%>"
flush="true" /></p>
<% }
} // end item can be ordered
%>
<br>
</form>
</td></tr></table> <%-- end table for bin content and
header --%>
</td></tr></table>
<p> </p>
<p> </p>
</td></tr></table> <%-- end page table --%>
<% } // end item loaded
%>
<%@ include file="ibeCZzdBottom.jsp" %>
<!-- ibeCCtdItemDetail.jsp end -->my bad...didnt think anyone was gonna come in ...lol......nothing populates in the second drop down...I was thinking of making a separate page and just pass the parameter in, bu i never used jsp include.....any suggestions on how to get this thing working??
-
Unable to load file ..jsp
Hi
When Iam forwarding a jsp page to other jsp page after
some condition meets using jsp forward than some times
when i access it it gives
"Unable to load as it is not a top level class"
for file while is forwarded
for example:--
<jsp:forward page="Login.jsp">
<jsp:param name="user" value="<%=user%>"/>
</jsp:forward>
it gives login.jsp not a top level class
unable to load
note :---- all files in one directory
suggestion requiredactually it depends on your JSP engine. I'm not sure but I've a doubt that once you have flushed some response , you may get an error in forwarding ( in some of the jsp engines, but I think in tomcat it's fine).
you could try by using "buffer" property in such a way that no response is flushed before you forward the JSP page. -
I have setup JSP & MySQL but how can i Connect it to eche other ?
I feel sory by asking this qustion but i tried very enough
100 mile start from 1 mile ^_^
I have tested JSP files by http://localhost:8080/test.jsp
and it works very will
also i have already installd MySQL and i can create databases and tables by http://localhost/phpMyAdmin
so what i have to do else to connect JSP to MySQL ? , ( if nothing )
how can i test that MySQL Connected with JSP, so that i can display data from database ?
Best Regards
JMalikcreate a java bean, which is just similar to a java class and put the database connection there so you wouldn't have to include that code in all you jsps everytime you connect to the database
this is for DbConnection.java
package connection;
import java.sql.*;
import java.io.*;
public class DBConnection
private Connection con;
public DBConnection()
try
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/yourfolder?user=yourusername&password=yourpassword");
catch (Exception e)
e.printStackTrace();
public Connection getConnection()
return con;
public void close()
try
con.close();
catch(Exception e)
e.printStackTrace();
}in another bean/class which connects to your database,
say for example this is SelectUsers.java
public String[] selectActiveUsers(int id) throws Exception, SQLException
try
con = new DBConnection().getConnection();
Statement stmt = con.createStatement();
String ins = "<your select statement>";
stmt.executeUpdate(ins);
con.close();
stmt.close();
catch (SQLException se)
System.out.println("SQL Exception: " + se.getMessage() + "not connected");
se.printStackTrace(System.out);
}and in your jsp, instantiate the class
users.jsp
SelectUsers su = new SelectUsers();
String[] users = su.selectActiveUsers(1);got it?
Message was edited by:
shuini -
JSP iframe src = 'a file that is created by another JSP' Error
I have a JSP file that has an iframe into which, I want to load a .pdf file.
Firstly, the iframe should contain nothing(and it does so), and when I press a button, another JSP is called, which creates a .pdf file and puts it in the WEB directory of the Application. After creating the .pdf, this JSP calls the first JSP, that now is supposed to load into the iframe the created .pdf.
The .pdf is created corectly, but I believe that a synchronization is needed, so that the first JSP should not load the .pdf until the second doesn't finish writing it.
I tried with delaying, but no success.And then I tried with synchronized(page){ }, but there are many possibilities instead of "page", and I came to no success.
Here are my two JSPs:
<%--
Document : user
Created on : 06.05.2008, 13:27:06
Author : razvanb
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>UserAbruf</title>
<script type="text/javascript" language="JavaScript" src="jsscript.js">
</script>
</head>
<style type="text/css">
body {background-color : white}
</style>
<body>
<%response.setHeader("Cache-Control", "must-revalidate, no-cache");
response.setHeader("Expires", "0"); %>
<div style="position:absolute;top:0px;left:0px;width:150px;height:100%" id = "userDiv">
<form name="userForm" action="userForm" method="post">
<br>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<img src="sign.gif" alt="LOGO" style="position:relative;left:20%"/>
</td>
</tr>
<tr>
<td>
<input type="button" value="Neuer Abruf" style="position:relative;top:20px;left:30%" onclick="gotopage('NeuAbrufS.jsp')">
<br>
<br>
<input type="button" value="Abruf bearbeiten" style="position:relative;top:20px;left:30%">
</td>
</tr>
</table>
</form>
</div>
<%
if(session.getAttribute("isource") == null){
System.out.println("before pressing");%>
<div style="position:absolute;top:0px;left:200px;width:100%;height:100%" id = "userFrameDiv">
<h1 style="position:relative;left:7%;font-family:verdana"> Mobilit�tsabruf-Managementsystem </h1>
<iframe width="850" height="590" id="frame1" name="frame1" ></iframe>
</div>
<% }
if(session.getAttribute("isource") != null) {
System.out.println("after pressing:"+ (String)session.getAttribute("isource"));%>
<div style="position:absolute;top:0px;left:200px;width:100%;height:100%" id = "userFrameDiv">
<h1 style="position:relative;left:7%;font-family:verdana"> Mobilit�tsabruf-Managementsystem </h1>
<iframe src = <%=(String)session.getAttribute("isource")%> width="850" height="590" id="frame1" name="frame1" ></iframe>
</div>
<%session.setAttribute("isource", null);
}%>
</body>
</html>
<%-- <%=(String)session.getAttribute("isource")%> --%>
<%-- Abruf 38 LwA.pdf --%>
<%--
Document : NeuAbrufS
Created on : 08.05.2008, 13:45:02
Author : razvanb
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Abruf</title>
</head>
<body>
<%-- start web service invocation --%><hr/>
<%
try {
localPackage.UserWsdlService service = new localPackage.UserWsdlService();
localPackage.UserWsdlPortType port = service.getUserWsdlPort();
// TODO initialize WS operation arguments here
localPackage.UserAccount input = new localPackage.UserAccount();
input.setUsername((String)session.getAttribute("username"));
input.setPassword((String)session.getAttribute("password"));
System.out.println(input.getUsername() + ", " + input.getPassword());
// TODO process result here
boolean result = port.createNewPdf(input);
} catch (Exception ex) {
// TODO handle custom exceptions here
java.util.Random random = new java.util.Random();
int randomNr = random.nextInt();
session.setAttribute("isource", "Abruf 38 LwA.pdf?rubbish="+ randomNr);
request.getRequestDispatcher("user.jsp").forward(request, response);
%>
<%-- end web service invocation --%><hr/>
<%-- <jsp:forward page="user.jsp"></jsp:forward> --%>
</html>Hi Alha,
when that file is locked by the other program you can't do anything about that - apart from quitting that other program. Probably this isn't an option to you…
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
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. -
JSP : Tiles Error �tag.getAsString� : component context is not defined
JSP : Tiles Error �tag.getAsString� : component context is not defined
I�m working with Struts 1.1 and Tiles, under Tomcat 5.0.16
My application works fine using Struts 1.1 alone, however, when attempting to run the application in a �Tiles� environment, I get an error:
�
javax.servlet.jsp.JspException: Error - tag.getAsString : component context is not defined. Check tag syntax
�
I have �defined� this in my �tiles-defs.xml� file, and as far as I can tell, everything else is configured properly (I have looked over the included Struts document examples, and others on the web, and I seem to have everything configured identically).
What am I missing???
I have created a series of �mostly� empty JSP files, for simplicity sake.
JSP FILES:
- header.jsp
- footer.jsp
- menu.jsp
- rootLayout.jsp
- user.jsp
- show_user.jsp
- error.jsp
- defaultContentPage.jsp
All JSP files contain:
<%@ taglib uri="/WEB-INF/lib/struts-tiles.tld" prefix="tiles" %>
and
�
<title>
<tiles:getAsString name="title"/>
</title>
�
My �tiles-defs.xml�: =================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
<tiles-definitions>
<!-- ================ RootLayout ======================= -->
<definition name=".root.layout" path="/jsp/rootLayout.jsp" >
<put name="title" value="Default title"/>
<put name="header" value="/jsp/header.jsp"/>
<put name="menu" value="/jsp/menu.jsp"/>
<put name="content" value="/jsp/defaultContentPage.jsp"/>
<put name="footer" value="/jsp/footer.jsp"/>
</definition>
<!-- ================ Extentions ======================= -->
<!-- User -->
<definition name=".view.user" extends=".root.layout">
<put name="title" value="Welcome to the User Form."/>
<put name="content" value="/jsp/user.jsp"/>
</definition >
<!-- Save -->
<definition name=".view.save" extends=".root.layout">
<put name="title" value="Welcome to the Show User Form."/>
<put name="content" value="/jsp/show_user.jsp"/>
</definition >
<!-- Error -->
<definition name=".view.error" extends=".root.layout">
<put name="title" value="Error Message."/>
<put name="content" value="/jsp/error.jsp"/>
</definition >
</tiles-definitions>
My �struts-config.xml�: ==============================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<!-- ========== FormBeans =================================== -->
<form-beans>
<form-bean name="userForm" type="biz.seamrog.strutstest.model.state.UserForm"/>
</form-beans>
<!-- ========== Action Mapping Definitions=================== -->
<action-mappings>
<!-- Action using normal forward syntax...
<action path="/user"
forward="/jsp/user.jsp">
</action>
-->
<!-- Action using a "Tiles" forward syntax...
The "forward" path mappings are defined in a file named
"../WEB-INF/tiles-defs.xml
-->
<action path="/user"
forward=".view.user">
</action>
<!-- Action using normal forward syntax...
<action path="/save"
type="biz.seamrog.strutstest.model.logic.SaveAction"
name="userForm" scope="request"
input="/jsp/user.jsp">
<forward name="success" path="/jsp/show_user.jsp"/>
<forward name="failure" path="/jsp/error.jsp"/>
</action>
-->
<!-- Tiles syntax -->
<action path="/save"
type="biz.seamrog.strutstest.model.logic.SaveAction"
name="userForm" scope="request"
input="/jsp/user.jsp">
<forward name="success" path=".view.show_user"/>
<forward name="failure" path=".view.error"/>
</action>
</action-mappings>
<!-- ============== Global Forwards ======================== -->
<global-forwards>
<!-- NOTE: paths with "." syntax are Tiles defined paths,
all other paths follow conventional "/path/to/file.jsp syntax
-->
<forward name="user" path=".view.user"/>
<forward name="show_user" path=".view.show_user"/>
<forward name="error" path=".view.error"/>
<forward name="cssBase" path="/stylesheets/common.css"/>
</global-forwards>
<!-- ============= Plug-ins =============== -->
<!-- Tiles Plug-in -->
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/>
<set-property property="definitions-parser-validate" value="true" />
<set-property property="moduleAware" value="true" />
</plug-in>
</struts-config>
My �web.xml�: =====================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'>
<web-app>
<servlet>
<!--
MyController extends org.apache.struts.action.ActionServlet
NOTE: The servlet could also be specified specifying the
default Struts ActonServlet...
<servlet-name>controller</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
...I have chosen to extend here just for practice sake.
-->
<!--
<servlet-name>MyController</servlet-name>
<servlet-class>biz.seamrog.strutstest.controller.MyController</servlet-class>
-->
<servlet-name>MyController</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<!--
Point to Struts configuration file(s)
-->
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<!-- Tiles config -->
<init-param>
<param-name>definitions-config</param-name>
<param-value>/WEB-INF/tiles-defs.xml</param-value>
</init-param>
<!-- This is the added Application parameter: -->
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResource</param-value>
</init-param>
<!-- end -->
<load-on-startup>5</load-on-startup>
</servlet>
<!--
All incoming requests that end in .do, send to MyController.
-->
<servlet-mapping>
<servlet-name>MyController</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<!--
Send initial requests to the login page for this application
-->
<welcome-file-list>
<welcome-file>/jsp/user.jsp</welcome-file>
</welcome-file-list>
<!--
Make all of the necessary related Struts JSP custom tag libraries
available and define where to find them.
-->
<taglib>
<taglib-uri>/WEB-INF/lib/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/lib/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/lib/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/lib/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/lib/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/lib/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/lib/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/lib/struts-tiles.tld</taglib-location>
</taglib>
</web-app>
My �rootLayout.jsp�: ================================================
<%@page contentType="text/html"%>
<%@ taglib uri="/WEB-INF/lib/struts-tiles.tld" prefix="tiles" %>
<html>
<header>
<title>
<tiles:getAsString name="title" />
</title>
<body>
<tiles:get name="header"/>
<tiles:get name="menu"/> <tiles:get name="content"/>
<tiles:get name="footer"/>
</body>
</html>I found an entry in the Mail Archive for Struts. I got it working. My working code is below. You need to in the base JSP import the header and put the 'title' out to it.
tiles:def file:
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">
<tiles-definitions>
<definition name=".petstore.Base" path="/common/petstorecommon.jsp">
<put name="title" value ="${title}"/>
<put name="header" value="/common/header.jsp"/>
<put name="message" value="/common/message.jsp"/>
<put name="content" value="${content}"/>
<put name="navbar" value="/common/navbar.jsp"/>
</definition>
<definition name="petstore.Login" extends=".petstore.Base" >
<put name="title" value="Login Page" />
<put name="content" value="/Logon.jsp"/>
<put name="test1" value="test1value"/>
</definition>
base tile def:
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
<%@ page contentType="text/html;charset=windows-1252"%>
<html:html>
<head>
<html:base/>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>pet store common (jsp)</title>
</head>
<body>
<tiles:insert attribute="header">
<%-- both of these attributes are accessible from header.jsp It works!!! --%>
<tiles:put name="title" beanName="title" beanScope="tile" />
<tiles:put name="test1" beanName="test1" beanScope="tile" />
</tiles:insert>
<%-- <tiles:get name="header" /> --%>
<tiles:get name="message" />
<tiles:get name="content" />
<tiles:get name="navbar" />
</body>
</html:html>
Getting access to the title value in the header.jsp file:
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
<html>
<head>
<tiles:getAsString name="title" />
<tiles:getAsString name="test1" />
</head>
<body>
</body>
</html> -
How to send a message from Servlet to JSP
Dear all,
I have JSP, with JavaScript (AJAX). If the user click on the button, the text will be sent to a Servlet parsed by doGet() and the user get a response to his input, without reloading a page.
How can I send a message to the users (JSP) from Servlet, if he didn't clicked any button and to other visitor of the page also? Is it possible? I think like a chat, the server sends a message to all users who are subscribed.
I don't know, what should I get from user, maybe session, that I could send him personal or common messages in his textarea. I should also invoke some JavaScript function to update his page. I have met some chats, you don't do nothing and get messages. It is also without a JavaScript timer, which invokes doGet() method. Asynchronous, only when there is a message.
Please help me with a problem.
Thanks in advance.Hai ,
You can send any message through response.sendRedirect();
here is the coding try it
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SimpleCounter extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/plain");
PrintWriter out = res.getWriter();
String username="java";
res.sendRedirect("http://localhost:8080/yourprojectname/jspfile.jsp?username="+username);
} -
Maintain session in JSP after using filters
I have to extend this application to maintain the session , because there are 10 jsp pages in my application.
When the user logs in , and hits a tab(which should redirect to another jsp page - assume users.jsp) the page is redirected back to the login page (instead of the users.jsp page) because of the filter.
How do I maintain the session here , so that a user who is logged in (with user name and password) could access the other pages instead of just being redirected back to the login.jsp page.
this is my filter page
package com.bea.genesis.tenantmgmt.utils;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class FacesRedirectFilter implements Filter {
public void doFilter(ServletRequest req,ServletResponse res,FilterChain chain)
throws ServletException, IOException
HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse response = (HttpServletResponse)res;
//String uri = request.getRequestURI();
String relativePath = request.getServletPath();
if ((relativePath.indexOf("/pages/") >= 0) && relativePath.endsWith(".jsf")) {
//int length = uri.length();
//String newAddress = uri.substring(0, length-3) + EXTENSION;
//response.sendRedirect("login.jsf");
RequestDispatcher rd = request.getRequestDispatcher("login.jsf");
rd.forward(req, res);
chain.doFilter(request, response);
public void destroy() {
// TODO Auto-generated method stub
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub
Please reply
thanksThanks for the reply , How do I test in the filter whether the user is loged in or not.(I dont have clue , how to do tht)
this is my login Bean ---
import java.util.Map;
import javax.faces.context.FacesContext;
public class LoginBean extends AbstractBean {
private String loginId;
private String password;
private LoginService loginService;
private LoginValidator loginValidator = new LoginValidator();
private TenantProfileService tenantProfileService;
public String getLoginId() {
return loginId;
public void setLoginId(String _loginId) {
loginId = _loginId;
public String getPassword() {
return password;
public void setPassword(String _password) {
password = _password;
public LoginService getLoginService() {
return loginService;
public void setLoginService(LoginService loginService) {
this.loginService = loginService;
*public String login() {*
* String authenticationStatus = GenesisConstants.RESULT_FAIL;*
* appLogger.enterMethod(this, "login", loginId);*
* if (loginValidator.validateData(this)) {*
* try {*
* long profileId = loginService.authenticateUser(loginId,*
* password);*
* TenantProfileData tenantProfileData = retrieveTenantProfile(profileId);*
* if (tenantProfileData == null || !tenantProfileData.getStatus().equalsIgnoreCase(*
* GenesisConstants.TENANT_STATUS_ACTIVE))*
* throw new LoginException(*
* "Tenant profile Not Active for the user.");*
* authenticationStatus = GenesisConstants.RESULT_SUCCESS;*
* } catch (LoginException le) {*
* appLogger.error("Error in User Authentication", le.getMessage());*
loginValidator.addErrorMessage(null, le.getMessage());
* authenticationStatus = GenesisConstants.RESULT_FAIL;*
appLogger.exitMethod(this, "login", loginId);
return authenticationStatus;
public TenantProfileData retrieveTenantProfile(long profileId) {
appLogger.enterMethod(this, "viewTenant");
FacesContext facesContext = FacesContext.getCurrentInstance();
Map<String, Object> sessionMap = facesContext.getExternalContext()
.getSessionMap();
appLogger.debug("profileId==", profileId + "");
TenantProfileData tenantProfileData = new TenantProfileData();
try {
appLogger.debug("invoking TenantProfileService.getTenantById");
tenantProfileData = tenantProfileService.getTenantById(profileId);
appLogger
.debug("successfully completed TenantProfileService.getTenantById");
} catch (TenantProfileServiceException te) {
appLogger.debug("exception in TenantProfileService.getTenantById");
throw new DataException(te.getMessage());
sessionMap.put("tenantProfileData", tenantProfileData);
appLogger.exitMethod(this, "viewTenant");
return tenantProfileData;
public TenantProfileService getTenantProfileService() {
return tenantProfileService;
public void setTenantProfileService(
TenantProfileService tenantProfileService) {
this.tenantProfileService = tenantProfileService;
PLEASE HELP
THANKS -
hi, i have a jsp page .... this page submit for a servlet
<form action="./servlet/authLogin">
...... the servlet if all is ok send me to another jsp
getServletConfig().getServletContext().getRequestDispatcher("//home.jsp").forward(req,res);
the browser location adress = http://localhost:8080/SCM/servlet/authLogin
but im this page is home.jsp ......
in this page i have a button
<input type="button" onclick="javascript:self.location.replace('newUser.jsp')">
then when i click it the page was not found because in the location address we found this ... http://localhost:8080/SCM/servlet/newUser.jsp .....
when should be http://localhost:8080/SCM/newUser.jspSHOW !!!!!!!!!!!!!!!!!!!!!!!!!!! I DONE THAT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I CHANGE THE LINE
//getServletConfig().getServletContext().getRequestDispatcher("//users.jsp").forward(req,res);
FOR THIS ONE !!!!!!!!!!!!!!!!!!!!!!
res.sendRedirect("../users.jsp");
THANKS GOD !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=]
BRASIL HUNGRY RULEZZZZZZZZZZZZZZZZZZ -
Can any one tell me how param is used in Jsp:setProperty ?
Hi Can anyone please explain me with example how param attribute is used in <jsp:setProperty>?
I have gone through the java doc but it still not clear to me....Try the [JSP syntax reference|http://java.sun.com/products/jsp/syntax/2.0/syntaxref2025.html#8856]
It is very rare that you would use the param attribute, as most times you have your incoming parameter and bean property having the same name.
Example:
Say you navigate to http://localhost:8080/myApp/myPage.jsp?username=Bob
That sends a request parameter "username" with the value "Bob"
If we have a bean which also has a property username (getUsername(), setUsername()) (ie the property and the parameter have the same name) you can use the following jsp code:
<jsp:useBean id="user" class="com.mypackage.User"/>
<jsp:setProperty name="user" property="username">Translates approximately into
User user = new User();
user.setUsername(request.getParameter("username"));If instead the bean had a property "username" but the parameter was "userId"
<jsp:useBean id="user" class="com.mypackage.User"/>
<jsp:setProperty name="user" property="username" param="userId">
User user = new User();
user.setUsername(request.getParameter("userId"));Cheers,
evnafets -
Existing session is becoming null when returning from jsp
Hi Guys !
I have an urgent requirement to meet in few days from now and got stuck with session problem in servlet.
Scenario :-
For the first time when i call a servlet a new sessoin is created and after some validations i forward to a jsp which has some links.
I have printed sessoin ids from both the servlet and jsp and they are same.
Now when i clicked on the link in jsp , the servlet is called but session is lost its becoming null.
Servlet Code :
HttpSession session = request.getSession(false);
if(session ==null){
// create session code ....using getSession(true)
RequestDispatcher r = servletcontext.getRequestDispatcher(resp.encodeURL("/user.jsp"));
jsp code:-
<a href="<%=response.encodeURL(/application/servlet/ViewUser") %">" > View User </a>
GUYS GIVE ME A SUGGESTION IN THIS REGARD AS SOON AS POSSIBLE .....
Thanks in advance !
Aparna</a>Hi,
Session Create Code in Login file
HttpSession hs = req.getSession( true );
hs.setAttribute( "user", lb.getUsername() ); // username() is ur unique id
Session Tracking code in all file
HttpSession hs=request.getSession();
if ( hs == null || hs.getAttribute( "user" ) == null )
response.sendRedirect ( "./index.jsp" );
Logout code
HttpSession hs=req.getSession(false);
hs.setAttribute( "user", null );
hs.invalidate();
res.sendRedirect ( "./index.jsp" );
// I hope this snippet will help u..
Maybe you are looking for
-
Why does Keynote 09 started to crash on heavy presentations?
I have always worked with big, heavy presentations, that includes text, images and videos, but a few weeks ago Keynote 09 is crashing when I try to opne it!!! I have my entire life in those presentation and can't even think about losing it! I have tr
-
I just got a new LaCie external 3TB hard drive connected to my Mac Pro via FireWire 800. I started using it as a secondary Time Machine backup drive, but when Time Machine is backing up to it, I cannot use my iSight camera with Messages. I am still u
-
HP Photosmart 5520, Windows 7, "Now Printing" stays on printer screen
My HP Photosmart 5520, inkjet printer, windows 7 OS, has "now Printing" on the small screen all the time. Iyogi says it works find from their end, but I can't get it to print and turn off the "now printing". How do I reurn it to normal? Need detailed
-
I need help fixing my partitions without wiping my current install?
I deleted my BootCamp partition. Now everything seems a mess. In the end, I am trying to reinstall the bootcamp partition with Windows 7, but I am running into problems. It looks like there might be an issue with my partition layout. Here are the res
-
Object Serialization Question.
Hello, I'm working on a MUD client and I have a DataHolder class to store settings. I'm having problems getting the serialization process to work properly, could someone please give me an example of how to serialize this class and then restore it aga