IllegalArgumentException on getSession(true)
we are using unclustered WL 4.03, and are getting an illegal arugment
exception from getSession(true) as it tries to instantiate a new cookie
object, with a presumably malformed name parameter. Our guess was that
the cookie on the client machine was in fact malformed, but we were
wondering why that exception wasn't handled properly. Is this something
that was fixed with later versions of code, or is there a reason that
exception is unhandled, or is it a known bug? any info would be
appreciated.
Sam
Hi,
We are investigating the problem. We will let you as soon as we
have a fix.
Thanks
Prasad
vlad wrote:
> Hello all,
>
> I am getting NullPointerException() when trying to generate a new
> session with HttpSession session=
> (HttpServetRequest)request.getSession(true)
>
> This happens in the cluster of WLAS 4.5.1 SP4 with in-memory session
> replication after it runs for a while
> and has lots of active sessions. (Solaris 2.6, jdk 1.2.2 and jdk
> 1.2.1_04). When this happens, the server has to be killed :-(
>
> Any ideas why this might be happening?
>
> Thanks a lot.
>
> Vlad.
Similar Messages
-
Null returned from request.getSession( true )
It is my understanding that when you call getSession on an instance of
HttpServletRequest with a parameter of true, it should return the existing
session (if there is one) or a new session. It should never return null.
Unfortunately, that is exactly what we are seeing. Has anybody else had a
similar problem? We've seen it three times at this point. It only seems to
happen after stress or extended usage of the WebLogic server (several days).
After null is returned, it is always returned until you restart the server.
We are running WebLogic 4.5.1 (service pack 2) with clustering and in-memory
replication of session data. We use jview (Microsoft's VM) on Windows NT
Server 4.0 (service pack 6).
Thanks,
Walter Bodwell
Evity, Inc.
Copied from the API:
getSession
public HttpSession getSession(boolean create)
Returns the current HttpSession associated with this request or, if
necessary, creates a new session for the request. Use true for create to
create a new session, or false to return the current HttpSession.
If create is false and the request has no valid HttpSession, this method
returns null.
To make sure the session is properly maintained, you must call this method
at least once before you write any output to the response. Newly created
sessions (that is, sessions for which HttpSession.isNew returns true) do not
have any application-specific state.
Parameters:
true - to create a new session for this request; false to return the current
session
Returns:
the HttpSession associated with this request or null if create is false and
the request has no valid session
getSession
public HttpSession getSession()
Returns the current session associated with this request, or if the request
does not have a session, creates one.
Returns:
the HttpSession associated with this request
Hope that helps,
-Andrew
Walter Bodwell <[email protected]> wrote in message
news:[email protected]...
> The spec itself is not very clearly written, but seems to imply that
> getSession( true ) only creates a session if there is not one already
> associated with the request:
>
> getSession
>
> Returns the current valid session associated with this request. If this
> method is called with no arguments, a session will be created for the
> request if there is not already a session associated with the request. If
> this method is called with a boolean argument, then the session will be
> created only if the argument is true.
>
> The API documentation is much more clear (the important words being if
> necessary):
>
> public abstract HttpSession getSession(boolean create)
>
> Gets the current valid session associated with this request, if create is
> false or, if necessary, creates a new session for the request, if create
is
> true.
>
> Walter
>
> Andrew Robinson <[email protected]> wrote in message
> news:[email protected]...
> > In 2.1 getSession(true) ALWAYS creates a new session, getSession(false)
> > returns the current session (or null).
> > With getSession(), it returns the existing session, or creates a new one
> if
> > there is not one. Check out the API, very important difference.
> >
> > -Andrew
> >
> >
> > Walter Bodwell <[email protected]> wrote in message
> > news:[email protected]...
> > > Doesn't getSession() just call getSession( true )? The descriptions
for
> > the
> > > two sound identical.
> > >
> > > Thanks,
> > > Walter
> > >
> > > Andrew Robinson <[email protected]> wrote in message
> > > news:[email protected]...
> > > > Try using getSession(), no arguments, it is in the 2.1 servlet spec
> > > >
> > > > Walter Bodwell <[email protected]> wrote in message
> > > > news:[email protected]...
> > > > > It is my understanding that when you call getSession on an
instance
> of
> > > > > HttpServletRequest with a parameter of true, it should return the
> > > existing
> > > > > session (if there is one) or a new session. It should never
return
> > > null.
> > > > > Unfortunately, that is exactly what we are seeing. Has anybody
else
> > had
> > > a
> > > > > similar problem? We've seen it three times at this point. It
only
> > > seems
> > > > to
> > > > > happen after stress or extended usage of the WebLogic server
> (several
> > > > days).
> > > > > After null is returned, it is always returned until you restart
the
> > > > server.
> > > > >
> > > > > We are running WebLogic 4.5.1 (service pack 2) with clustering and
> > > > in-memory
> > > > > replication of session data. We use jview (Microsoft's VM) on
> Windows
> > > NT
> > > > > Server 4.0 (service pack 6).
> > > > >
> > > > > Thanks,
> > > > > Walter Bodwell
> > > > > Evity, Inc.
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
-
Difference between getSession() and getSession(true)
I am new to servlets. I couldn't find any difference between request.getSession()
and request.getSession(true) methods. Could any one help me plese.
Thanks.I am new to servlets. I couldn't find any difference
between request.getSession()
and request.getSession(true) methods. Could
any one help me plese.
Thanks.getSession() is a convenience method shortcut for getSession(true). There is no difference. There is a difference between getSession() and getSession(false) though...
(ie, if getSession(false) will not make a new session if one does not already exist...) -
请问各位高手,为什么我的weblogic在session失效后,重新getSession(true)老抛异常?
我们公司的weblogic不知道被改了什么配置,一个session超时后,再调用getSession(true)方法,老是抛NullPointerException异常。但我自己装的weblogic6.1就没这个问题。异常如下:
<2004-3-29 下午01时46分03秒> <Error> <HTTP> <[WebAppServletContext(3194122,test
,/test)] Servlet failed with Exception
java.lang.NullPointerException
at weblogic.servlet.internal.session.SessionData.<init>(SessionData.java
:117)
at weblogic.servlet.internal.session.MemorySessionData.<init>(MemorySess
ionData.java:9)
at weblogic.servlet.internal.session.MemorySessionContext.getNewSession(
MemorySessionContext.java:19)
at weblogic.servlet.internal.ServletRequestImpl.getNewSession(ServletReq
uestImpl.java:2111)
at weblogic.servlet.internal.ServletRequestImpl.getSession(ServletReques
tImpl.java:1925)
请问各位高手,怎么解决这个问题?应该是设置了session store方式,但实际的store方式不可写.否则不应该出现这种问题,既然getSession(ture,那么它尽可能返回一个存在的会话,否则创建一个新会话.既然已经过期,那么那个原来"存在的"会话已经被remove,剩下的唯一选择就是新建会话.
新建会话就要看session的store mode,好象插入数据库记录,你总是在插入成功后才告诉用户插入成功,你不能先提示用户插入成功然后而去做插入.
那么在新建会话时,如果新建不成功,肯定会返回一个null的异常给用户.新建不成功的原因能的哪几种?如果是集群中,有可能Memcopy不成功.而在单机中,容器在内存中是没有多大可能新建不成功的.那么应该是store的时候不能向设定的介质上写(File,DataBase不可访问).所以你第一先从这方面查找,我说的只是最大可能,并不是说100%就是这个原因.如果Store方式是文件,看看文件访问权限,如果是WIN平台看看文件路径是否有中文名或空格.如果是数据库方式看看数据库配置.session Store能不能真正访问数据库. -
Session - getSession(true)
I have two servlet . In first sevrlet i m creating a session and i am using setAttribute(uname,"abc"). Then i m redirecting to second servlet . In second servlet i have getSession(true). That means i m creating a new session. Then i am giving :
if (session != null)
String name = (String) session.getAttribute("uname");
// some more code here
else
out.println("You are not authorised to access this information");
Since it is new session, 'else' code should be executed , but its going in 'if' condition..There are two methods from which you can get HttpSession object
HttpServletRequest.getSession()
Returns the current session associated with this request, or if the request does not have a session, creates one.
HttpServletRequest.getSession(boolean create)
Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session.
If create is false and the request has no valid HttpSession, this method returns null.
To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity and is asked to create a new session when the response is committed, an IllegalStateException is thrown.
regards, -
ADF 10g:HttpServletRequest.getSession vs ExternalContext.getSession
Hi all,
I'm reviewing some code in our application and I would like to confirm my understanding of how to properly use session attributes on the view layer.
In my servlet doFilter method I get my session using:
HttpSession session = servletRequest.getSession(true);
I also came across this blog post:
http://andrejusb.blogspot.com/2012/01/how-to-access-session-scope-in-adf-bc.html
which calls getSession from FacesContext.getCurrentInstance().getExternalContext.getSession
http://docs.oracle.com/cd/E17802_01/j2ee/j2ee/javaserverfaces/1.2/docs/api/javax/faces/context/ExternalContext.html#getSession(boolean)
Am I correct in my understanding that according to the javadoc, the getExternalContext.getSession returns the same HttpSession object as in HttpServletRequest.getSession?
Many thanks
WesHi,
yes, this is correct
Frank -
Difference between getSession() and getSession(boolean)
What is the difference between sessionObj.getSession() and sessionObj.getSession(true)?
The reason would be if you wanted to check if the user had a session but didn't want to create a new session if they didn't.
i.e.
HttpSession session = request.getSession(false);
if (session == null) { // we know the user hasn't got a session and we haven't created one for them
response.sendRedirect("login.jsp"); // make them login
return;
} -
Issue upon upgrading from 10.1.2 to 10.1.3.3
Hi,
i am upgrading the AS from 10.1.2 to 10.1.3.3,
i have deployed the same ear on oc4j 10.1.3.3 which i have deployed on 10.1.2
the issue is, upon session time out on 10.1.3.3 it give error and doesn't redirect to session expire page(defined in web.xml) but the same ear works fine on 10.1.2 :
error message is :
java.lang.IllegalArgumentException: path must begin with a "/" at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpApplication.getRequestDispatcher(HttpApplication.java:1668) at com.bidm.misc.service.bo.SessionExpireFilter.doFilter(SessionExpireFilter.java:99) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:623) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:302) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].server.http.AJPRequestHandler.run(AJPRequestHandler.java:190) at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.3.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) at java.lang.Thread.run(Thread.java:595)
Thanks,
DJhi steve,
yes i am using a filter to handle the session timeout, here is the code in web.xml
root context for the application is: /MyApp
location for expire.jsp is : /MyApp/expire.jsp
<filter>
<filter-name>SessionExpireFilter</filter-name>
<filter-class>com.myapp.SessionExpireFilter</filter-class>
<init-param>
<param-name>redirect</param-name>
<param-value>expire.jsp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SessionExpireFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
code for SessionExpireFilter.java:
public class SessionExpireFilter implements Filter {
private static boolean no_init = true;
private static Log log = LogFactory.getLog(SessionExpireFilter.class);
private FilterConfig config;
private String redirect;
public SessionExpireFilter() {
redirect = null;
public void init(FilterConfig filterconfig) throws ServletException {
config = filterconfig;
no_init = false;
initRoute();
public void destroy() {
config = null;
public void doFilter(ServletRequest servletrequest,
ServletResponse servletresponse, FilterChain filterchain)
throws IOException, ServletException {
HttpServletRequest httpservletrequest = (HttpServletRequest) servletrequest;
HttpSession httpsession = httpservletrequest.getSession(true);
if ((httpsession == null) ||
(httpservletrequest.getRequestedSessionId() == null) ||
(redirect == null)) {
if ((httpservletrequest.getRequestURI().indexOf("login.jsp") != -1) ||
((httpservletrequest.getRequestURI().indexOf("bookingAdviceAction.do") != -1) &&
(httpservletrequest.getParameterMap() != null) &&
httpservletrequest.getParameterMap().containsKey("servletAction")) ) {
filterchain.doFilter(servletrequest, servletresponse);
} else {
//session is expired
RequestDispatcher requestdispatcher = config.getServletContext().getRequestDispatcher(redirect);
requestdispatcher.forward(servletrequest, servletresponse);
} else {
// session is expired
HttpServletResponse httpservletresponse = (HttpServletResponse) servletresponse;
ServletContext servletcontext = config.getServletContext();
// It won't happen so frequent
if (getRedirect(redirect)) {
httpservletresponse.sendRedirect(redirect);
} else {
// these jsp won't be filtered, login.jsp & index.jsp
if ((httpservletrequest.getRequestURI().indexOf("login.jsp") != -1) ||
(httpservletrequest.getRequestURI().indexOf("index.jsp") != -1)) {
filterchain.doFilter(servletrequest, servletresponse);
} else {
RequestDispatcher requestdispatcher = servletcontext.getRequestDispatcher(redirect);
requestdispatcher.forward(servletrequest, servletresponse);
public void initRoute() {
//log.debug("in initRoute");
redirect = config.getInitParameter("redirect");
if (redirect == null) {
if (log.isDebugEnabled()) {
log.debug(
"Session Expire filter: could not get an initial parameter redirect");
redirect = "expire.jsp";
private boolean getRedirect(String s) {
//log.debug("in getRedirect");
int i = s.indexOf(":");
if (i <= 0) {
return false;
} else {
String s1 = s.substring(0, i).toUpperCase();
return s1.startsWith("HTTP");
Thanks,
DJ -
How I can replace following code as getServlet method is deprecated.
getServletContext().getServlet("trapenv");this is Authenticator.java
package trap.content;
import javax.servlet.*;
import javax.servlet.http.*;
import trap.*;
import trap.publishing.*;
import java.io.*;
import java.util.Properties;
import java.util.Hashtable;
@SuppressWarnings("serial")
public class Authenticator
extends TRAPServletBase{
Default constructor
public Authenticator() {
super();
public final void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
doPost(req,res);
Overrides the default doGet() to perform login function.
@param req HttpServletRequest that encapsulates the request to the servlet.
@param res HttpServletResponse that encapsulates the response from the servlet.
@exception javax.servlet.ServletException
If the request could not be handled.
@exception java.io.IOException
If there is an error writing to the output stream.
@SuppressWarnings({ "unchecked" })
public final void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
try {
res.setContentType("text/html");
PrintWriter out = getServletPrintWriter(res);
System.out.println("getting properties now");
// Properties properties = getTRAPEnvironment().getProperties();
Properties properties = (Properties) getServletConfig().getServletContext().getAttribute("TRAPProperties");
System.out.println("got properties now");
String loginTemplate = properties.getProperty("TRAP.template.login");
String expiredTemplate = properties.getProperty("TRAP.template.expired");
String mainTemplate = properties.getProperty("TRAP.template.mainFrameSet");
String userid = req.getParameter("userid");
String passwd = req.getParameter("passwd");
if(userid == null) {
userid = "";
if(passwd == null) {
passwd = "";
// Overall properties are passed through to HttpTRAPConnection
// to initialize ORB...
Properties connectionProperties = getProperties();
HttpTRAPConnection conn = new HttpTRAPConnection(
connectionProperties, req.getSession(true)
TRAPSession session = conn.login(userid, passwd);
if(session.isPasswordExpired()) {
Hashtable table = new Hashtable();
table.put("MESSAGE","Your password has expired.<BR>" + "Please enter a new password now.");
// printTemplate(expiredTemplate, out, table);
} else {
Hashtable myData = new Hashtable();
myData.put("DEFAULT_SERVLET",session.getMenu().defaultMenuItem.url);
// printTemplate(mainTemplate, out,myData);
} catch(AccessViolation access) {
HTMLElement element = HTMLElementFactory.getHTMLElement(
HTMLElementFactory.ERROR_ELEMENT
element.printHTML(getServletPrintWriter(res), access);
} catch(Exception error) {
printError(getServletPrintWriter(res), getClass().getName(), error);
}this is TRAPServletBase
package trap.publishing;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import aif.persist.DbError;
import trap.*;
@SuppressWarnings("serial")
public class TRAPServletBase
extends HttpServlet {
@SuppressWarnings("unused")
private CachedFileTemplateManager templateMgr = null;
Default constructor, calls default HttpServlet constructor.
public TRAPServletBase() {
super();
Returns the TRAPSession object for this session, or throws
an AccessViolation if the session has not logged in.
@param req The HttpServletRequest for this servlet thread.
@return TRAPSession for the servlet thread.
@exception trap.AccessViolation
If the user has not yet logged in.
@exception aif.persist.DbError
if a database error occurs
public TRAPSession getTRAPSession(HttpServletRequest req)
throws AccessViolation, DbError {
HttpTRAPConnection conn = HttpTRAPConnection.getInstance(req);
if(conn == null) {
throw new AccessViolation(AccessViolationType.Authentication);
} else {
return conn.getTRAPSession();
Returns the TrapEnvironmentServlet.
@return The TrapEnvironmentServlet.
@exception javax.servlet.ServletException
If there is an error retrieving the environment.
public TRAPEnvironmentServlet getTRAPEnvironment()
throws ServletException {
System.out.println("getting TRAPEnvironmentServlet");
return (TRAPEnvironmentServlet)
// getServletContext().getServlet("trapenv");
// getServletContext().getNamedDispatcher("trapenv");
// getServletContext().getAttribute ("trapenv") ;
getServletContext().getRequestDispatcher("/servlet/trapenv");
Prints a template as if getTemplateManager().getTemplate().printHTML()
were called with null data.
@param templateName The name of the template to retrieve.
@param out The output stream to print to.
@exception javax.servlet.ServletException
If there is an error printing the template.
public void printTemplate(String templateName, PrintWriter out)
throws ServletException {
try {
HTMLElement element = null;
element = getTRAPEnvironment().getTemplateElement(templateName);
element.printHTML(out, null);
} catch(TemplateNotFoundException tnfe) {
throw new ServletException(tnfe.getMessage());
Prints a template as if getTemplateManager().getTemplate().printHTML()
were called.
@param templateName The name of the template to retrieve.
@param out The output stream to print to.
@param data The data object for the template.
@exception javax.servlet.ServletException
If there is an error printing the template.
public void printTemplate(String templateName, PrintWriter out, Object data)
throws ServletException {
try {
HTMLElement element = null;
element = getTRAPEnvironment().getTemplateElement(templateName);
element.printHTML(out, data);
} catch(TemplateNotFoundException tnfe) {
throw new ServletException(tnfe.getMessage());
Logs the error message to the servlet logging mechanism and
prints a standard error page to the output stream specified.
@param out The print writer to render the page to.
@param where The class/location where the error occurred.
@param error The exception which caused the error.
public void printError(PrintWriter out, String where, Exception error)
throws ServletException, IOException {
log(error, where);
HTMLElement element = HTMLElementFactory.getHTMLElement(
HTMLElementTypes.ERROR_ELEMENT
element.printHTML(out, error);
Utility method that takes the HttpServletResponse, retrieves the output
stream, and creates a new PrintWriter to write to it.
@param res The HttpServletResponse to retrieve the output stream from.
@return The PrintWriter that writes to the response's output stream.
@exception java.io.IOException
If the output stream cannot be obtained from the
HttpServletResponse.
public PrintWriter getServletPrintWriter(HttpServletResponse res)
throws IOException {
return new PrintWriter(new OutputStreamWriter(res.getOutputStream()));
Returns the value of the specified property from the properties file
that was loaded on initialization.
@param propertyName The name of the property to retrieve.
@return The value of the specified property.
@exception javax.servlet.ServletException
If the TRAPEnvironment cannot be found.
@exception java.lang.IllegalArgumentException
If the property is not found.
public String getProperty(String propertyName)
throws ServletException {
return getTRAPEnvironment().getProperty(propertyName);
Returns the value of the specified property from the properties file
that was loaded on initialization.
@param propertyName The name of the property to retrieve.
@param required <code>true</code> if the property must exist.
@return The value of the specified property.
@exception javax.servlet.ServletException
If the TRAPEnvironment cannot be found.
@exception java.lang.IllegalArgumentException
If the property is not found, and it was required.
public String getProperty(String propertyName, boolean required)
throws ServletException {
return getTRAPEnvironment().getProperty(propertyName, required);
Returns the properties object loaded at initialization.
@return The properties object.
@exception javax.servlet.ServletException
If the TRAPEnvironment cannot be found.
public Properties getProperties()
throws ServletException {
TRAPEnvironmentServlet t = new TRAPEnvironmentServlet();
return t.getProperties();
public void log(String reason) {
try {
super.log(reason);
} catch(Exception error) {
System.err.println("Unable to use servlet logging for:");
System.err.println(reason);
public void log(Exception why, String reason) {
try {
getServletContext().log(reason);
} catch(Exception error) {
System.err.println("Unable to use servlet logging for:");
System.err.println(reason);
why.printStackTrace();
and this is TRAPEnvironmentServlet
package trap.publishing;
import java.io.*;
import java.util.Hashtable;
import java.util.Properties;
import javax.servlet.*;
import javax.servlet.http.*;
@SuppressWarnings("serial")
public class TRAPEnvironmentServlet
extends TRAPServletBase
implements TemplateManager {
The system configuration information.
private Properties properties = null;
The template manager that loads templates.
private CachedFileTemplateManager templateMgr = null;
private boolean initialized = false;
private final static String TOKEN_NAME = "MESSAGE";
private final static String TOKEN_DEFAULT_REPLACEMENT =
"Enter your user id and password to log into TRAP";
Construct the servlet.
public TRAPEnvironmentServlet() {
super();
Initialize the servlet.
@param config The servlet config object, containing the init parameter
TRAP.properties=[path].
@exception javax.servlet.ServletException
If there is an error initializing the servlet.
public void init(ServletConfig config)
throws ServletException {
System.out.println("in the init of TRAPEnvironmentServlet");
if(initialized) {
System.err.println("attempt made to reinitialize servlet.");
return;
super.init(config);
try {
if(config == null) {
throw new ServletException(
"ServletConfig is not available for initialization."
// String propertiesPath = config.getInitParameter("TRAP.properties");
InputStream is = getClass().getClassLoader().getResourceAsStream("config/trap.ini");
// properties.load(is);
/* if(propertiesPath == null || propertiesPath.equals("")) {
throw new ServletException(
"No initialize parameters specified for TRAPEnvironmentServlet."
properties = new Properties();
try {
//properties.load(new FileInputStream(propertiesPath));
properties.load(is);
String templateRoot = properties.getProperty("TRAP.templateRoot");
String loadAllStr = properties.getProperty("TRAP.loadAllTemplates");
boolean loadAll = false;
if(loadAllStr != null) {
loadAll = new Boolean(loadAllStr).booleanValue();
templateMgr = new CachedFileTemplateManager(templateRoot, loadAll);
config.getServletContext().setAttribute("TRAPProperties", properties);
} catch(java.io.IOException ioe) {
log(ioe, "Unable to load properties file.");
} catch(TemplateNotFoundException tnfe) {
log(tnfe, "Unable to load one or more templates.");
} catch(Exception error) {
log(error, "An error occurred while initializing the servlet.");
// config.getServletContext().setAttribute("TRAPProperties", properties);
initialized=true;
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
Hashtable<String, String> table = new Hashtable<String, String>();
String why = req.getParameter("why");
if(why == null) {
table.put(TOKEN_NAME, TOKEN_DEFAULT_REPLACEMENT);
} else {
table.put(TOKEN_NAME, why);
res.setContentType("text/html");
Properties properties = this.getProperties();
String loginTemplate = properties.getProperty("TRAP.template.login");
this.printTemplate(loginTemplate, getServletPrintWriter(res), table);
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
PrintWriter out = new PrintWriter(new OutputStreamWriter(res.getOutputStream()));
out.println("<HTML>");
out.println(" <BODY>");
out.println(" <CENTER>");
out.println(" <H1>");
out.println(" This servlet should not be reference by a browser.");
out.println(" </H1>");
out.println(" </CENTER>");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
Returns the value of the specified property from the properties file
that was loaded on initialization.
@param propertyName The name of the property to retrieve.
@return The value of the specified property.
@exception java.lang.IllegalArgumentException
If the property name is not found.
public String getProperty(String propertyName) {
return getProperty(propertyName, true);
Returns the value of the specified property from the properties file
that was loaded on initialization.
@param propertyName The name of the property to retrieve.
@param required <code>true</code> if the property must exist.
@return The value of the specified property.
@exception java.lang.IllegalArgumentException
If the property name is not found, but was required.
public String getProperty(String propertyName, boolean required) {
String property = properties.getProperty(propertyName);
if(required && property == null) {
throw new IllegalArgumentException(
propertyName + " was not found in the properties object."
return property;
Returns the properties object loaded at initialization.
@return The properties object.
public Properties getProperties() {
System.out.println("getting properties now");
return properties;
Wraps access to the template manager, returning the template root.
@return The template root.
public String getTemplateRoot() {
return templateMgr.getTemplateRoot();
Wraps access to the template manager, sets the new template root.
@param root The new template root.
public void setTemplateRoot(String root) {
templateMgr.setTemplateRoot(root);
Wraps access to the template manager, returns the
template associated with the specified name.
@param name The name of the template to return.
@return The HTMLElement representing the loaded template.
@exception trap.publishing.TemplateNotFoundException
If the template cannot be successfully loaded.
public HTMLElement getTemplateElement(String name)
throws TemplateNotFoundException {
return templateMgr.getTemplateElement(name);
}this is my code
thanks for help -
I get the following error, but don't know why it can't find the file. Is there anything in this script that would call "\" instead of "/"? Is there any line of code that will switch a wayward "\" back?
01-09-24 09:37:02 - path="" :jsp: init
2001-09-24 09:43:42 - path="" :LoginServlet: init
2001-09-24 09:44:15 - path="" :CourseServlet: init
2001-09-24 09:46:48 - path="" :LessonServlet: init
2001-09-24 09:46:54 - path="" :Error: /usr/local/apache/sites/tesco.spinweb.net/htdocs/cmi/courses\Food Service/Intro/AU00.html (No such file or directory)
The script is below. Thanks for any help anyone can provide me.
import cmi.xml.AU;
import cmi.xml.Block;
import cmi.xml.CourseReader;
import cmi.xml.CSFElement;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServlet;
import org.jdom.JDOMException;
public class LessonServlet extends HttpServlet
public void init (ServletConfig config) throws ServletException
super.init (config);
try {
Class.forName (GlobalData.DatabaseDriverName);
_jdbcConnection = DriverManager.getConnection (GlobalData.DatabaseName, "tesco", "scorm");
_jdbcConnection.setAutoCommit (true);
//should I do this?
//_jdbcConnection.setAutoCommit (false);
//load serialized course data
loadCourseData();
catch (Exception xcp) {
xcp.printStackTrace();
getServletContext().log("Error: " + xcp.getMessage());
public void doGet( HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
boolean normalMode = true;
try {
HttpSession session = request.getSession (true);
//can I load the session given the id??
//System.out.println ("Lesson.valid session " + session.getId() + ": " + request.isRequestedSessionIdValid());
response.setContentType ("text/html");
JDBCHelper dbHelper = new JDBCHelper (_jdbcConnection);
//get student ID
Integer studentID = (Integer) session.getAttribute ("studentID");
//get course ID
Integer courseID = (Integer) session.getAttribute ("courseID");
//get lesson ID
String lessonID = request.getParameter ("lessonID");
if (lessonID == null) {
lessonID = (String) session.getAttribute ("lessonID");
if (studentID == null || courseID == null || lessonID == null) {
//reset session data by re-logging the user
sendProfileError (response.getOutputStream());
return;
//store lesson ID in session
session.setAttribute ("lessonID", lessonID);
String auID = request.getParameter ("auID");
String mode = request.getParameter ("mode");
if (mode != null) {
session.setAttribute ("mode", mode);
else {
mode = (String) session.getAttribute ("mode");
if (mode.equalsIgnoreCase ("review")) {
normalMode = false;
else {
normalMode = true;
//synchronize access to course hash table
synchronized (_courseHash)
//make sure _courseHash is in tact
if (_courseHash == null) {
//try reloading it....
loadCourseData();
if (_courseHash == null) {
//error
response.getOutputStream().close();
throw new IOException ("Corrupt course data");
if (! _courseHash.containsKey (courseID.toString())) {
//try reloading it....
loadCourseData();
if (! _courseHash.containsKey (courseID.toString())) {
//error
response.getOutputStream().close();
throw new IOException ("Corrupt course data (course not found)");
if (auID == null) {
//show course menu
Hashtable hash = (Hashtable) _courseHash.get (courseID.toString());
sendAvailableAUs (hash, studentID.intValue(), courseID.intValue(), lessonID, response.getOutputStream(), response, dbHelper);
return;
//if AU has not been attempted, initialize it
Integer auDataID = new Integer (getAUDataID (studentID.intValue(), courseID.intValue(), lessonID, auID, dbHelper));
//if (getAUDataID (studentID.intValue(), courseID.intValue(), lessonID, auID, dbHelper) == -1) {
if (auDataID.intValue() == -1) {
int newID = initializeAUData (studentID.intValue(), courseID.intValue(), lessonID, auID, dbHelper);
dbHelper.addAUToPath (studentID.intValue(), courseID.intValue(), lessonID, auID);
auDataID = new Integer (newID);
session.setAttribute ("AUID", auID);
session.setAttribute ("AUDataID", auDataID);
sendAU (studentID.intValue(), courseID.intValue(), lessonID, auID, auDataID.intValue(), normalMode, response.getOutputStream(), dbHelper);
//to do: detailed messages should be sent to the client depending on which
// exception was thrown. Don't have one try/catch....have one for each situation
catch (Exception e) {
e.printStackTrace();
getServletContext().log("Error: " + e.getMessage());
public void destroy()
try {
if (_jdbcConnection != null) {
_jdbcConnection.close();
catch (Exception ignored) {}
private int initializeAUData (int studentID, int courseID, String lessonID, String auID, JDBCHelper dbHelper)
String sqlQuery = null;
ResultSet results = null;
try {
//get student's name
sqlQuery = "SELECT Full_Name" +
" FROM " + GlobalData.StudentTable +
" WHERE Student_ID = " + studentID;
results = dbHelper.doQuery (sqlQuery);
if (! results.next()) {
//error
return -1;
String studentName = results.getString (1);
results.close();
//the lock prevents CMIServlet from reading AU_ID before it's committed
//sqlQuery = "LOCK TABLES " + GlobalData.AUDataTable + " WRITE;";
//System.out.println (sqlQuery);
//dbHelper.executeUpdate (sqlQuery);
sqlQuery = "Insert Into " + GlobalData.AUDataTable +
"(Course_ID, Lesson_ID, AU_ID, student_id, student_name, lesson_location, credit," +
" lesson_status, entry, exit, score_raw, score_max, score_min, total_time," +
" session_time, lesson_mode, suspend_data, launch_data, Evaluation_ID, Objective_ID)" +
" Values (" + courseID + ", '" + lessonID + "', '" + auID + "', " + studentID + ", '" + studentName + "'," +
" 'NA', 'credit'," + " 'not attempted', 'ab-initio', " + "'NA', " + 0 + ", " + 0 + ", " + 0 +
", '00:00:00.0', '00:00:00.0', " + " 'normal'" + ", 'NA', " + "'NA', " + 0 + ", " + 0 + ");";
dbHelper.executeUpdate (sqlQuery);
return getAUDataID (studentID, courseID, lessonID,auID, dbHelper);
//sqlQuery = "UNLOCK TABLES;";
//System.out.println (sqlQuery);
//dbHelper.executeUpdate (sqlQuery);
catch (Exception e) {
e.printStackTrace();
getServletContext().log("Error: " + e.getMessage());
return -1;
private int getAUDataID (int studentID, int courseID, String lessonID, String auID, JDBCHelper dbHelper)
throws SQLException
String sqlQuery = "SELECT AUData_ID, lesson_status, lesson_mode, exit" +
" FROM " + GlobalData.AUDataTable +
" WHERE student_id = " + studentID +
" AND Course_ID = " + courseID +
" AND Lesson_ID = " + "'" + lessonID + "'" +
" AND AU_ID = '" + auID + "';";
ResultSet results = dbHelper.doQuery (sqlQuery);
if (results.next()) {
return results.getInt ("AUData_ID");
return -1;
private void sendAU (int studentID, int courseID, String lessonID, String auID, int auDataID, boolean normalMode, ServletOutputStream htmlOut, JDBCHelper dbHelper)
throws IOException, ClassNotFoundException
Hashtable hash = null;
synchronized (_courseHash)
hash = (Hashtable) _courseHash.get (String.valueOf (courseID));
if (hash == null) {
loadCourseData();
hash = (Hashtable) _courseHash.get (String.valueOf (courseID));
if (hash == null) {
throw new IOException ("Corrupt course data (course not found)");
AU au = (AU) hash.get (auID);
try {
if (! normalMode) {
dbHelper.setReviewMode (auDataID);
String courseFileName = getFileName (String.valueOf (courseID), dbHelper);
File file = new File (courseFileName);
//create absolute path to file so we can resolve relative URLs
String newFileName = file.getParent() + "\\" + au.getLaunchParams();
BufferedReader buf = new BufferedReader (new FileReader (newFileName));
PrintWriter htmlWriter = new PrintWriter (htmlOut);
String temp;
htmlWriter.write (getAUHtml (au.getLaunchParams()));
htmlWriter.flush();
htmlWriter.close();
catch (Exception e) {
e.printStackTrace();
getServletContext().log("Error: " + e.getMessage());
private String getAUHtml (String path){
path = path.replace ('\\','/');
String response;
response = "<html>\n" +
"<head>\n" +
"</head>\n" +
"<body>\n" +
"<script language=\"JavaScript\">\n" +
"document.location = \"/cmi/courses/" + path + "\"\n" +
//"win = window.open ('','displayWindow','menubar=yes,scrollbars=yes,status=yes,width=300,height=300');\n" +
//"window.onload = \"win.close();\"" +
"</script>\n" +
"</body>\n" +
"</html>\n";
return response;
private void sendAvailableAUs (Hashtable hash, int studentID, int courseID, String lessonID, ServletOutputStream out, HttpServletResponse response, JDBCHelper dbHelper)
StringBuffer buf = new StringBuffer (200);
Block block = (Block) hash.get (lessonID);
AU au = null;
try {
Vector completedAUs = dbHelper.getCompletedAUs (studentID, courseID, lessonID);
buf.append ("<html>\n" +
"<head>\n" +
"<title>" + block.getTitle() + " units</title>\n" +
"<script language=\"JavaScript\">\n" +
"function go() {\n" +
" var form = document.goForm;\n" +
" var index = form.gotoSelect.selectedIndex;\n" +
" if (index == 0) {\n" +
" document.location = \"/servlet/CourseServlet?courseID=" + courseID + "\";\n" +
" }\n" +
" else if (index == 1) {\n" +
" top.restart();\n" +
" }\n" +
"}\n" +
"</script>\n" +
"</head>\n" +
"<body background=\"/cmi/images/marble.jpg\">\n" +
"<center><h1><b><u>" + block.getTitle() + "</u></b></h1></center>\n" +
"<p></p>\n<p></p>\n" +
"<b>" + block.getTitle() + " contains the following units: </b>\n" +
"<dl>\n");
Enumeration enum = block.getChildren();
while (enum.hasMoreElements()) {
String temp = (String) enum.nextElement();
CSFElement element = (CSFElement) hash.get (temp);
if (element.getType().equals ("au")) {
au = (AU) element;
if (completedAUs.contains (au.getID())) {
buf.append ("<dt><p><img src=\"/cmi/images/node2.gif\"><a href=\"/servlet/LessonServlet?lessonID=" + block.getID() + "&auID=" + au.getID() + "&mode=review\">" + au.getTitle() + " (<i>review</i>) </a></p></dt>\n");
else {
buf.append ("<dt><p><img src=\"/cmi/images/node.gif\"><a href=\"" + response.encodeURL ("/servlet/LessonServlet?lessonID=" + block.getID() + "&auID=" + au.getID() + "&mode=normal") + "\">" + au.getTitle() + "</a></p></dt>\n");
else if (element.getType().equals ("block")) {
buf.append ("<dt><p><img src=\"/cmi/images/folder.gif\"><a href=\"" + response.encodeURL ("/servlet/LessonServlet?lessonID=" + element.getID() + "&mode=normal") + "\">" + element.getTitle() + "</a></p></dt>\n");
buf.append ("</dl>\n" +
"<br><br>\n" +
"<form name=\"goForm\">\n" +
"<select name=\"gotoSelect\">\n" +
" <option value=\"lesson\">Lesson Menu</option>\n" +
" <option value=\"exit\">Exit LMS</option>\n" +
"</select>\n" +
"<input type=\"button\" value=\"Go\" onClick=\"go()\">\n" +
"</form>\n" +
"</body>\n" +
"</html>");
PrintWriter writer = new PrintWriter (out);
writer.write (buf.toString());
writer.flush();
writer.close();
catch (Exception e) {
e.printStackTrace();
getServletContext().log("Error: " + e.getMessage());
private String getFileName (String courseID, JDBCHelper dbHelper)
throws ClassNotFoundException, SQLException
ResultSet results = null;
String fileName = null;
String sqlQuery = "SELECT CourseFile" +
" FROM Course" +
" WHERE Course_ID = " + Integer.parseInt (courseID) + ";";
results = dbHelper.doQuery (sqlQuery);
if (results.next()) {
fileName = results.getString (1);
else {
//need to do more than this :)
System.out.println("crap");
results.close();
return fileName;
private void loadCourseData()
throws IOException, ClassNotFoundException
//load serialized course data
File file = new File (GlobalData.DataFileName);
if (! file.exists()) {
//error
throw new FileNotFoundException (GlobalData.DataFileName + " not found.");
FileInputStream fis = new FileInputStream (GlobalData.DataFileName);
ObjectInputStream ois = new ObjectInputStream (fis);
_courseHash = (Hashtable) ois.readObject();
ois.close();
private void sendProfileError (ServletOutputStream out)
String html = "<html>\n" +
"<body>\n" +
"<p>An error has occurred with your profile. Please " +
"<a href=\"\" onClick=\"top.restart(); return true\">login again</a>" +
"</body>\n" +
"</html>\n";
PrintWriter writer = new PrintWriter (out);
writer.write (html);
writer.flush();
writer.close();
private Connection _jdbcConnection;
private Hashtable _courseHash;I know that is where my error is, but why and where is
the script calling it up way?You wrote it right? check out the sendAU() method, there is line
String newFileName = file.getParent() + "\\" + au.getLaunchParams(); -
Calling all java gurus - i cant figure out what is wrong with my code
please can someone see why a null pointer exception is being thrown and how do i fix it?
my current code which throws the null pointer is as below - the key issues that i need some java expert to tell me about is
1. is the usage of resultSet ok in the way i'm doing it , i'm not able to look at the code in debug mode as don't have an IDE and don't know how to do a log4j setup. - i tried doing an out.println("Got........"); but servlet keeps on forwarding the request object to results.jsp even when i comment out the code. and recomplie and restart tomcat 4.1.
2. is the way i'm declaring the List object and the adding stuff to bean and then stuffing bean into list ok?
3. why is the List object null? although i know the query works fine - and that using the below original code where only one row of data was being retrieved and set into bean worked fine.
current code with problem in the List object:
package com.bt.ros;
import java.util.*;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import javax.sql.*;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
* This class is a servlet that searches for a Finder Aid.
* @author
public class FinderAidsSearchS extends HttpServlet {
* This is the static initializer,
* executed the first time this class is referred to.
* It makes sure the JDBC pool driver is loaded.
* This method examines an HTTP request and searches for the
* specified Finder Aid record in the database. It then redirects
* the response to the <tt>Results.jsp</tt> JSP page.
public void service(HttpServletRequest req, HttpServletResponse res)
throws IOException
HttpSession session = req.getSession(true);
//res.setContentType("text/html");
//PrintWriter out = res.getWriter( );
//out.println("<HTML>");
//out.println("<HEAD>");
//out.println("<TITLE>");
//out.println("A Servlet Example");
String year = req.getParameter("Year");
String year_range = req.getParameter("Year_Range");
String county = req.getParameter("County");
Connection conn = null;
try {
//example code from tomcatmanual
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/rosDS");
//Connection
conn = ds.getConnection();
Statement stmt = conn.createStatement();
String select = "select * from abridgment where " +
"(a_county = '" + county +
"' AND a_year_date = " + year +
out.println("<DEBUG> <select> the select staement is : " + select);
stmt.execute(select);
ResultSet resultSet = stmt.getResultSet();
Results abridgeresults = new Results();
abridgeresults.setName("NaeemColl");
Abridgment varabridgment = null;
int nRows = 0;
while(resultSet.next()){
nRows++;
varabridgment = new Abridgment();
varabridgment.seta_county(county);
varabridgment.seta_year_date(Integer.parseInt(year));
varabridgment.seta_sub_year_volume(resultSet.getInt("a_sub_year_volume"));
// out.println("varabridgment - attributes are:");
//out.println("varabridgment - attributes are:" +varabridgment.geta_sub_year_volume());
//out.println("varabridgment - attributes are:"+resultSet.getInt("a_sub_year_volume"));
varabridgment.seta_page_id(resultSet.getString("a_page_id"));
varabridgment.seta_month_date(resultSet.getInt("a_month_date"));
varabridgment.seta_day_date(resultSet.getInt("a_day_date"));
varabridgment.seta_year_sequence(resultSet.getLong("a_year_sequence"));
varabridgment.seta_day_sequence(resultSet.getLong("a_day_sequence"));
varabridgment.seta_year_volume(resultSet.getInt("a_year_volume"));
varabridgment.seta_volume_id(resultSet.getString("a_volume_id"));
varabridgment.seta_summary(resultSet.getString("a_summary"));
varabridgment.seta_batch_id(resultSet.getLong("a_batch_id"));
varabridgment.seta_image_id(resultSet.getLong("a_image_id"));
abridgeresults.addAbridgment(varabridgment);
//trying to use vector construct
req.setAttribute("results",abridgeresults);
//session.setAttribute("results", abridgeresults);
stmt.close();
conn.close();
//out.println("</BODY>");
//out.println("</HTML>");
// String sURL = res.encodeRedirectURL("/rossearch/results.jsp");
try{
//TEMPCOMM res.sendRedirect(sURL);
req.getRequestDispatcher("/rossearch/results.jsp").forward(req, res);
//TEMPCODE
//out.println("</BODY>");
//out.println("</HTML>");
catch(Exception e){
System.err.println("Exception: FinderAidsSearchS.service: " + e);
catch (Exception e) {
System.err.println("Exception: FinderAidsSearchS.service: " + e);
original code that worked fine - for one test row retrieved by query
public void service(HttpServletRequest req, HttpServletResponse res)
throws IOException
HttpSession session = req.getSession(true);
res.setContentType("text/html");
PrintWriter out = res.getWriter( );
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>");
out.println("A Servlet Example");
out.println("</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("Using servlets");
// if (! checkParams(req, res))
// return;
String year = req.getParameter("Year");
String year_range = req.getParameter("Year_Range");
String county = req.getParameter("County");
Connection conn = null;
try {
//example code from tomcatmanual
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/rosDS");
//Connection
conn = ds.getConnection();
Statement stmt = conn.createStatement();
String select = "select * from abridgment where " +
"(a_county = '" + county +
"' AND a_year_date = " + year +
out.println("<DEBUG> <select> the select staement is : " + select);
stmt.execute(select);
ResultSet resultSet = stmt.getResultSet();
Abridgment abridgment = new Abridgment();
abridgment.seta_county(county);
abridgment.seta_year_date(Integer.parseInt(year));
// abridgment.a_sub_year_volume = Long.parseLong(c_phone);
if (resultSet.next()){
abridgment.seta_sub_year_volume(resultSet.getInt("a_sub_year_volume"));
abridgment.seta_page_id(resultSet.getString("a_page_id"));
abridgment.seta_month_date(resultSet.getInt("a_month_date"));
abridgment.seta_day_date(resultSet.getInt("a_day_date"));
abridgment.seta_year_sequence(resultSet.getLong("a_year_sequence"));
abridgment.seta_day_sequence(resultSet.getLong("a_day_sequence"));
abridgment.seta_year_volume(resultSet.getInt("a_year_volume"));
abridgment.seta_volume_id(resultSet.getString("a_volume_id"));
abridgment.seta_summary(resultSet.getString("a_summary"));
abridgment.seta_batch_id(resultSet.getLong("a_batch_id"));
abridgment.seta_image_id(resultSet.getLong("a_image_id"));
session.setAttribute("isNewAbridgment", new Boolean(false));
else{
session.setAttribute("isNewAbridgment", new Boolean(true));
out.println("<DEBUG> <AbridgmentSearchS-service> Abridgment not found: " + abridgment);
session.setAttribute("abridgment", abridgment);
stmt.close();
conn.close();
out.println("</BODY>");
out.println("</HTML>");
String sURL = res.encodeRedirectURL("/rossearch/results.jsp");
try{
res.sendRedirect(sURL);
catch(Exception e){
System.err.println("Exception: FinderAidsSearchS.service: " + e);
catch (Exception e) {
System.err.println("Exception: FinderAidsSearchS.service: " + e);
exception being thrown is:
2005-11-07 02:45:20 StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:536)
----- Root Cause -----
java.lang.NullPointerException
at org.apache.jsp.results_jsp._jspService(results_jsp.java:95)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
......etc..
the problem line in the results_jsp.java is:
for (int i = 0; i < myAbridgments.size(); i++) in a scriptlet in the jsp to retrieve the List of beans and go through each one as follows:
<% List myAbridgments = (List) request.getAttribute("results");
for (int i = 0; i < myAbridgments.size(); i++) {
abridgment = (Abridgment) myAbridgments.get(i);
%>ok then all wanabe java experts lets see who is the first and best at resolving this one!
i have 10 points on offer - and a HUGE AMOUNT of graditude and appreciation for any one who can help me resolve this - Thanks.Check replies here
http://forum.java.sun.com/thread.jspa?threadID=680127 -
Very poor implementation of XMLHttpRequest streaming with Safari for Window
I hope this post reaches Apple engineers. This is critical for us to resolve this. I am a member of the developer network, so if using incident support is necessary, it can be used. Do not hesitate to contact me with any questions. I have implemented a test to compare XMLHttpRequest streaming performance for different browsers. Safari for Windows 5.0.3 had the worst results compared to Chrome and Firefox. Furthermore, I think this problem was introduced after Safari 3. The test consists of a server pushing messages of about 350 bytes to the browser at a rate of about 300/s. Once server pushes 10,000 messages, it closes the connection and browser opens new one repeating the cycle. There were several problems associated with Safari: 1) Safari could not process much more then 300 messages/s, that is quite low. Chrome had no problem processing 1,000. If, for example, 500 m/s was used, Safari would quickly allocate hundreds of meg of memory and crash. 2) Safari starts with about 64MEG of memory allocated. Once the test page is opened, memory quickly climes to 150MEG and as test progresses to >400MEG. Once the connection closes, it drops to 150MEG again. Chrome's memory did not fluctuate at all staying at 32MEG for the same test. 3) CPU was steadily claiming as test progressed and then dropped as connection was reset, creating CPU spikes. It reached about 50% CPU before connection was closed. Chrome's CPU stayed at about 2% all the time. This is the code: Server. Should be run with the latest Java Tomcat 7. Configure Tomcat to use Http11NioProtocol: package test; import java.io.IOException; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.Date; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.catalina.comet.CometEvent; import org.apache.catalina.comet.CometProcessor; @SuppressWarnings("serial") public class WebFrameworkServletXHRReconnects extends HttpServlet implements CometProcessor { @Override public void event(CometEvent event) throws IOException, ServletException { HttpServletRequest request = event.getHttpServletRequest(); HttpServletResponse response = event.getHttpServletResponse(); if (event.getEventType() == CometEvent.EventType.BEGIN) { System.out.println("Begin for session: " + request.getSession(true).getId() + " " + response.getWriter()); response.setHeader("pragma", "no-cache,no-store"); response.setHeader("cache-control", "no-cache,no-store,max-age=0,max-stale=0"); event.setTimeout(Integer.MAX_VALUE); PrintWriter out = response.getWriter(); SimpleDateFormat formatter = new SimpleDateFormat("mm:ss: "); for (int i = 0; i < 10000; i++) { out.print("{\"messageType\":8448,\"requestId\":"0",\"eventType\":1,\"symbolId\" :[\"BAC.EA\",0],\"fields\":[{\"header\":"0",\"type\":6,\"data\":[3993,2]},{\"hea der\":"55",\"type\":6,\"data\":[1185,2]},{\"header\":54,\"type\":6,\"data\":[321 8,2]},{\"header\":"5",\"type\":6,\"data\":[6617,2]},{\"header\":52,\"type\":4,\" data\":[15]},{\"header\":"12",\"type\":6,\"data\":[1700,2]}]}"); out.flush(); if (i % 10 == 0) { try { //Thread.sleep(60); Thread.sleep(30); } catch (InterruptedException e) { } } if (i % 100 == 0) { System.out.println(formatter.format(new Date()) + i); } } out.close(); event.close(); } else if (event.getEventType() == CometEvent.EventType.ERROR) { event.close(); } else if (event.getEventType() == CometEvent.EventType.END) { event.close(); } } } client: <script type="text/javascript" src="log4js.js">
</script>
<script type="text/javascript">
var api;
var log = new Log(Log.DEBUG, Log.popupLogger);
var byteoffset;
var perocessedMessages;
function connect() {
perocessedMessages = 0;
byteoffset = 0;
id = 0;
api = new XMLHttpRequest;
api.onreadystatechange = onreadystatechange;
api.onerror = onerror;
log.debug('connect');
api.open("GET", "http://localhost/Test/Controller", true);
api.send("");
function onreadystatechange() {
switch (api.readyState) {
case 3:
change();
break;
case 4:
disconnect();
break;
function change() {
connected = true;
var buffer = api.responseText;
var newdata = buffer.substring(byteoffset);
byteoffset = buffer.length;
while (1) {
var x = newdata.indexOf("<activ>");
if (x != -1) {
y = newdata.indexOf("</activ>", x);
if (y != -1) {
processMessage(newdata.substring((x + 7), y));
newdata = newdata.substring(y + 8);
else {
break;
else {
break;
byteoffset = buffer.length - newdata.length;
function processMessage(msg) {
var objJson = eval('(' + msg + ')');
perocessedMessages++;
//if (perocessedMessages % 100 == 0) {
// log.debug('' + perocessedMessages);
function disconnect() {
log.debug('disconnect');
connect();
function onerror() {
log.debug('onerror');
</script>I hope this post reaches Apple engineers. This is critical for us to resolve this. I am a member of the developer network, so if using incident support is necessary, it can be used.
We're a user-to-user forum, ilyag. So it'd be better for you to use the Apple Bug Reporter if you want to ensure someone from Apple sees your post:
http://developer.apple.com/bugreporter/ -
Session Rules from Servlet to JSP
I'm getting a null pointer exception from the else statement in the JSP below when I check to see if a user has been authenticated by a servlet.
Are there any problems with the else statement to cause an exception?
<% /**Verify Authenticationt*/
HttpSession mysession = request.getSession();
String loginUrl = "/hr/servlet/SessionLoginServlet";
if (mysession==null)
response.sendRedirect(loginUrl);
else { //below code causing null pointer exception
String loggedIn = (String) mysession.getAttribute("loggedIn");
if (!loggedIn.equals("true"))
response.sendRedirect(loginUrl);
%>
The Servlet's doPost:
public void doPost(HttpServletRequest request, HttpServletResponse
response)throws ServletException, IOException {
String userName = request.getParameter("userName");
String password = request.getParameter("password");
if (login(userName, password, response)) {
//send cookie to the browser
HttpSession session = request.getSession(true);
session.setAttribute("loggedIn", new String("true"));
response.sendRedirect("/hr/jsp/PAStart.jsp");
else {
sendLoginForm(response, true);
}Unfortunately, no. You'll need to say:
if (loggedIn != null || !loggedIn.equals("true"))
It's how the equals() works for String objects. You need two objects to check equality. -
Unknown problem with JSP, JavaScript - Pls help
Hi Friends,
I am facing a strange problem. Explained it below. Kindly help me as it is really affecting my work. Thanks in advance.
I am working on building a web application using jsp, servlet, ejb. the IDE used is WSAD 5.1.2.
I have the below :
1 JSP - Input page - for user input entry
2. Java script1 - For all client side validations
Java script2 - For handling the data submission to servlet (as selected by user)
Javascript3 - Header & Menu Bar
3 Servlet - This actually retrieves the values from the hidden parameters, sets them in session and redirects the control back to the jsp.
Logic for one small iteration : Two drop downs are there. On selecting the first drop down the second drop down should be populated and the first drop down should display the user selected value.
1. When the user selects the first drop down onchange() event gets fired which calls a method in the javascript.
2. In the javascript I set the value of a hidden form field to the selected combo index and submit the form to the servlet
3. In the servlet, I retrieve the hidden request parameter (Index),
set the index in session. Do my business logic based on the value of the index. Set the collection (to be displayed) in second drop down in session.
4. Send the response back to the JSP.
5. In the JSP, we have a method which is called during the onload() event of the body
6. This method sets the user selected values in appropriate controls(by taking from session)
Problem faced: I have a javascript which creates the menu bar for my application and this i've included it in my jsp. I dont know whats wrong with this javascript, when it is commented out the page works perfectly fine. Both the user selected value and the collection are loaded exactly as expected. But when it is included the collection is loaded in the second drop down but the selected index of the first drop down is not set - the drop down gets reset to the default value.
Also on body load of my jsp, I call a javascript method which sets the current date in one text field of my form. Even this is not working fine when I include this javascript. I don't see any script error in this javascript in my browser though. Strange but guess something basic :(
I'm sure there is nothing to do with session. I've tried printing the entire flow. The Servlet sets the values correctly in session and they are also correctly available in the JSP page. The JSP also gets loaded with the user selected values but something happens on page load which clears the values to default.
Am also confused in what way javascript is related to this, coz when I remove it things are working fine.
Am really helpless here pls do the needful. any help is appreciated.
Header.js [which includes the menu bar code]
document.write("<!-- COMMON HEADER CODE -->")
document.write(" <table id='mplPageHeader' cellspacing='0' cellpadding='2' border='0'>")
document.write(" <tr> ")
document.write(" <td rowspan='2' bgcolor='#FFFFFF' width='1%'>")
document.write(" <a href='http://www.web.com' target='_top'>")
document.write(" <img src='./images/ford.gif' alt='BLogistics' border='0'>")
document.write(" </a> ")
document.write(" </td>")
document.write(" <td rowspan='2' class='appTitle' title='Mp' width='1%'>MP&L</td>")
document.write(" <td class='appTitle' title='M R'>M R</td>")
document.write(" <td class='pageIdentifier'>"+' '+"</td>");
document.write(" </tr>")
document.write(" <tr>")
document.write(" <td class='pageTitle' nowrap></td>");
document.write(" <td class='dateInfo' nowrap>Thu Jan 22 2004 12:24 PM</td>")
document.write(" </tr>")
document.write(" </table>")
document.write("<!-- Display Menu Items -->")
document.write("<div id='navigationMenu'>")
document.write(" <script type='text/javascript' src='./javascript/MRmenuItem.js'></script>")
document.write(" <script type='text/javascript' src='./javascript/menuScript.js'></script>")
document.write("</div>")-------------------------------------------------------
Menu Bar Code
var AgntUsr=navigator.userAgent.toLowerCase();
var AppVer=navigator.appVersion.toLowerCase();
var DomYes=document.getElementById?1:0,NavYes=AgntUsr.indexOf("mozilla")!=-1&&AgntUsr.indexOf("compatible")==-1?1:0,ExpYes=AgntUsr.indexOf("msie")!=-1?1:0,Opr=AgntUsr.indexOf("opera")!=-1?1:0;
var DomNav=DomYes&&NavYes?1:0,DomExp=DomYes&&ExpYes?1:0;
var Nav4=NavYes&&!DomYes&&document.layers?1:0,Exp4=ExpYes&&!DomYes&&document.all?1:0;
var MacCom=(AppVer.indexOf("mac")!= -1)?1:0,MacExp4=(MacCom&&AppVer.indexOf("msie 4")!= -1)?1:0,Mac4=(MacCom&&(Nav4||Exp4))?1:0;
var Exp5=AppVer.indexOf("msie 5")!= -1?1:0,Fltr=(AppVer.indexOf("msie 6")!= -1||AppVer.indexOf("msie 7")!= -1)?1:0,MacExp5=(MacCom&&Exp5)?1:0,PosStrt=(NavYes||ExpYes)&&!Opr?1:0;
var RmbrNow=null,FLoc,ScLoc,DcLoc,SWinW,SWinH,FWinW,FWinH,SLdAgnWin,FColW,SColW,DColW,RLvl=0,FrstCreat=1,Ldd=0,Crtd=0,IniFlg,AcrssFrms=1,FrstCntnr=null,CurOvr=null,CloseTmr=null,CntrTxt,TxtClose,ImgStr,ShwFlg=0,M_StrtTp=StartTop,M_StrtLft=StartLeft,StaticPos=0,LftXtra=DomNav?LeftPaddng:0,TpXtra=DomNav?TopPaddng:0,FStr="",M_Hide=Nav4?"hide":"hidden",M_Show=Nav4?"show":"visible",Par=MenuUsesFrames?parent:window,Doc=Par.document,Bod=Doc.body,Trigger=NavYes?Par:Bod;
var Ztop=100,InitLdd=0,P_X=DomYes?"px":"";
var OpnTmr=null;
if(PosStrt){if(MacExp4||MacExp5)LdTmr=setInterval("ChckInitLd()",100);
else{if(Trigger.onload)Dummy=Trigger.onload;
if(DomNav)Trigger.addEventListener("load",Go,false);
else Trigger.onload=Go}}
function ChckInitLd(){
InitLdd=(MenuUsesFrames)?(Par.document.readyState=="complete"&&Par.frames[FirstLineFrame].document.readyState=="complete"&&Par.frames[SecLineFrame].document.readyState=="complete")?1:0:(Par.document.readyState=="complete")?1:0;
if(InitLdd){clearInterval(LdTmr);Go()}}
function Dummy(){return}
function CnclSlct(){return false}
function RePos(){
FWinW=ExpYes?FLoc.document.body.clientWidth:FLoc.innerWidth;
FWinH=ExpYes?FLoc.document.body.clientHeight:FLoc.innerHeight;
SWinW=ExpYes?ScLoc.document.body.clientWidth:ScLoc.innerWidth;
SWinH=ExpYes?ScLoc.document.body.clientHeight:ScLoc.innerHeight;
if(MenuCentered.indexOf("justify")!=-1&&FirstLineHorizontal){
ClcJus();
var P=FrstCntnr.FrstMbr,W=Menu1[5],a=BorderBtwnMain?NoOffFirstLineMenus+1:2,i;
FrstCntnr.style.width=NoOffFirstLineMenus*W+a*BorderWidthMain+P_X;
for(i=0;i<NoOffFirstLineMenus;i++){
P.style.width=W-(P.value.indexOf("<")==-1?LftXtra:0)+P_X;
if(P.ai&&!RightToLeft)
P.ai.style.left=BottomUp?W-BorderColor-2+P_X:W-Arrws[4]-2+P_X;
P=P.PrvMbr
StaticPos=-1;
ClcRl();
if(TargetLoc)ClcTrgt();ClcLft();ClcTp();
PosMenu(FrstCntnr,StartTop,StartLeft);
if(RememberStatus)StMnu()}
function NavUnLdd(){Ldd=0;Crtd=0;SetMenu="0"}
function UnLdd(){
NavUnLdd();
if(ExpYes){var M=FrstCntnr?FrstCntnr.FrstMbr:null;
while(M!=null){if(M.CCn){MakeNull(M.CCn);M.CCn=null}
M=M.PrvMbr}}
if(!Nav4){LdTmr=setInterval("ChckLdd()",100)}}
function UnLddTotal(){MakeNull(FrstCntnr);FrstCntnr=RmbrNow=FLoc=ScLoc=DcLoc=SLdAgnWin=CurOvr=CloseTmr=Doc=Bod=Trigger=null}
function MakeNull(P){
var M=P.FrstMbr,Mi;
while(M!=null){Mi=M;
if(M.CCn){MakeNull(M.CCn);M.CCn=null}
M.Cntnr=null;M=M.PrvMbr;Mi.PrvMbr=null;Mi=null}
P.FrstMbr=null}
function ChckLdd(){
if(!ExpYes){if(ScLoc.document.body){clearInterval(LdTmr);Go()}}
else if(ScLoc.document.readyState=="complete"){if(LdTmr)clearInterval(LdTmr);Go()}}
function NavLdd(e){if(e.target!=self)routeEvent(e);if(e.target==ScLoc)Go()}
function ReDoWhole(){if(AppVer.indexOf("4.0")==-1)Doc.location.reload();else if(SWinW!=ScLoc.innerWidth||SWinH!=ScLoc.innerHeight||FWinW!=FLoc.innerWidth||FWinH!=FLoc.innerHeight)Doc.location.reload()}
function Go(){
if(!Ldd&&PosStrt){
BeforeStart();
Crtd=0;Ldd=1;
FLoc=MenuUsesFrames?parent.frames[FirstLineFrame]:window;
ScLoc=MenuUsesFrames?parent.frames[SecLineFrame]:window;
DcLoc=MenuUsesFrames?parent.frames[DocTargetFrame]:window;
if(MenuUsesFrames){
if(!FLoc){FLoc=ScLoc;if(!FLoc){FLoc=ScLoc=DcLoc;if(!FLoc)FLoc=ScLoc=DcLoc=window}}
if(!ScLoc){ScLoc=DcLoc;if(!ScLoc)ScLoc=DcLoc=FLoc}
if(!DcLoc)DcLoc=ScLoc}
if(FLoc==ScLoc)AcrssFrms=0;
if(AcrssFrms)FirstLineHorizontal=MenuFramesVertical?0:1;
FWinW=ExpYes?FLoc.document.body.clientWidth:FLoc.innerWidth;
FWinH=ExpYes?FLoc.document.body.clientHeight:FLoc.innerHeight;
SWinW=ExpYes?ScLoc.document.body.clientWidth:ScLoc.innerWidth;
SWinH=ExpYes?ScLoc.document.body.clientHeight:ScLoc.innerHeight;
FColW=Nav4?FLoc.document:FLoc.document.body;
SColW=Nav4?ScLoc.document:ScLoc.document.body;
DColW=Nav4?DcLoc.document:ScLoc.document.body;
if(TakeOverBgColor){
if(ExpYes&&MacCom)FColW.style.backgroundColor=AcrssFrms?SColW.bgColor:DColW.bgColor;
else FColW.bgColor=AcrssFrms?SColW.bgColor:DColW.bgColor}
if(MenuCentered.indexOf("justify")!=-1&&FirstLineHorizontal)ClcJus();
if(FrstCreat||FLoc==ScLoc)FrstCntnr=CreateMenuStructure("Menu",NoOffFirstLineMenus,null);
else CreateMenuStructureAgain("Menu",NoOffFirstLineMenus);
ClcRl();
if(TargetLoc)ClcTrgt();ClcLft();ClcTp();
PosMenu(FrstCntnr,StartTop,StartLeft);
IniFlg=1;Initiate();Crtd=1;
SLdAgnWin=ExpYes?ScLoc.document.body:ScLoc;SLdAgnWin.onunload=Nav4?NavUnLdd:UnLdd;
if(ExpYes)Trigger.onunload=UnLddTotal;
Trigger.onresize=Nav4?ReDoWhole:RePos;
AfterBuild();
if(RememberStatus)StMnu();
if(Nav4&&FrstCreat){Trigger.captureEvents(Event.LOAD);Trigger.onload=NavLdd}
if(FrstCreat)Dummy();FrstCreat=0;
if(MenuVerticalCentered=="static"&&!AcrssFrms)setInterval("KeepPos()",250) }}
function KeepPos(){
var TS=ExpYes?FLoc.document.body.scrollTop:FLoc.pageYOffset;
if(TS!=StaticPos){var FCSt=Nav4?FrstCntnr:FrstCntnr.style;
FrstCntnr.OrgTop=StartTop+TS;FCSt.top=FrstCntnr.OrgTop+P_X;StaticPos=TS}}
function ClcRl(){
StartTop=M_StrtTp<1&&M_StrtTp>0?M_StrtTp*FWinH:M_StrtTp;
StartLeft=M_StrtLft<1&&M_StrtLft>0?M_StrtLft*FWinW:M_StrtLft}
function ClcJus(){
var a=BorderBtwnMain?NoOffFirstLineMenus+1:2,Sz=Math.round((PartOfWindow*FWinW-a*BorderWidthMain)/NoOffFirstLineMenus),i,j;
for(i=1;i<NoOffFirstLineMenus+1;i++){j=eval("Menu"+i);j[5]=Sz}
StartLeft=0}
function ClcTrgt(){
var TLoc=Nav4?FLoc.document.layers[TargetLoc]:DomYes?FLoc.document.getElementById(TargetLoc):FLoc.document.all[TargetLoc];
if(DomYes){while(TLoc){StartTop+=TLoc.offsetTop;StartLeft+=TLoc.offsetLeft;TLoc=TLoc.offsetParent}}
else{StartTop+=Nav4?TLoc.pageY:TLoc.offsetTop;StartLeft+=Nav4?TLoc.pageX:TLoc.offsetLeft}}
function ClcLft(){
if(MenuCentered.indexOf("left")==-1){
var Sz=FWinW-(!Nav4?parseInt(FrstCntnr.style.width):FrstCntnr.clip.width);
StartLeft+=MenuCentered.indexOf("right")!=-1?Sz:Sz/2;
if(StartLeft<0)StartLeft=0}}
function ClcTp(){
if(MenuVerticalCentered!="top"&&MenuVerticalCentered!="static"){
var Sz=FWinH-(!Nav4?parseInt(FrstCntnr.style.height):FrstCntnr.clip.height);
StartTop+=MenuVerticalCentered=="bottom"?Sz:Sz/2;
if(StartTop<0)StartTop=0}}
function PosMenu(Ct,Tp,Lt){
RLvl++;
var Ti,Li,Hi,Mb=Ct.FrstMbr,CStl=!Nav4?Ct.style:Ct,MStl=!Nav4?Mb.style:Mb,PadL=Mb.value.indexOf("<")==-1?LftXtra:0,PadT=Mb.value.indexOf("<")==-1?TpXtra:0,MWt=!Nav4?parseInt(MStl.width)+PadL:MStl.clip.width,MHt=!Nav4?parseInt(MStl.height)+PadT:MStl.clip.height,CWt=!Nav4?parseInt(CStl.width):CStl.clip.width,CHt=!Nav4?parseInt(CStl.height):CStl.clip.height,CCw,CCh,STp,SLt;
var BRW=RLvl==1?BorderWidthMain:BorderWidthSub,BTWn=RLvl==1?BorderBtwnMain:BorderBtwnSub;
if(RLvl==1&&AcrssFrms)!MenuFramesVertical?Tp=BottomUp?0:FWinH-CHt+(Nav4?MacCom?-2:4:0):Lt=RightToLeft?0:FWinW-CWt+(Nav4?MacCom?-2:4:0);
if(RLvl==2&&AcrssFrms)!MenuFramesVertical?Tp=BottomUp?SWinH-CHt+(Nav4?MacCom?-2:4:0):0:Lt=RightToLeft?SWinW-CWt:0;
if(RLvl==2){Tp+=VerCorrect;Lt+=HorCorrect}
CStl.top=RLvl==1?Tp+P_X:0;Ct.OrgTop=Tp;
CStl.left=RLvl==1?Lt+P_X:0;Ct.OrgLeft=Lt;
if(RLvl==1&&FirstLineHorizontal){Hi=1;Li=CWt-MWt-2*BRW;Ti=0}
else{Hi=Li=0;Ti=CHt-MHt-2*BRW}
while(Mb!=null){
MStl.left=Li+BRW+P_X;
MStl.top=Ti+BRW+P_X;
if(Nav4)Mb.CLyr.moveTo(Li+BRW,Ti+BRW);
if(Mb.CCn){if(RightToLeft)CCw=Nav4?Mb.CCn.clip.width:parseInt(Mb.CCn.style.width);
if(BottomUp)CCh=Nav4?Mb.CCn.clip.height:parseInt(Mb.CCn.style.height);
if(Hi){STp=BottomUp?Ti-CCh:Ti+MHt+2*BRW;SLt=RightToLeft?Li+MWt-CCw:Li}
else{SLt=RightToLeft?Li-CCw+ChildOverlap*MWt+BRW:Li+(1-ChildOverlap)*MWt;
STp=RLvl==1&&AcrssFrms?BottomUp?Ti-CCh+MHt:Ti:BottomUp?Ti-CCh+(1-ChildVerticalOverlap)*MHt+2*BRW:Ti+ChildVerticalOverlap*MHt+BRW}
PosMenu(Mb.CCn,STp,SLt)}
Mb=Mb.PrvMbr;
if(Mb){ MStl=!Nav4?Mb.style:Mb;PadL=Mb.value.indexOf("<")==-1?LftXtra:0;
PadT=Mb.value.indexOf("<")==-1?TpXtra:0;
MWt=!Nav4?parseInt(MStl.width)+PadL:MStl.clip.width;
MHt=!Nav4?parseInt(MStl.height)+PadT:MStl.clip.height;
Hi?Li-=BTWn?(MWt+BRW):(MWt):Ti-=BTWn?(MHt+BRW):MHt}}
status="Ready";RLvl--}
function StMnu(){
if(!Crtd)return;
var i,Pntr=FrstCntnr,Str=ScLoc.SetMenu?ScLoc.SetMenu:"0";
while(Str.indexOf("_")!=-1&&RememberStatus==1){
i=Pntr.NrItms-parseInt(Str.substring(0,Str.indexOf("_")));
Str=Str.slice(Str.indexOf("_")+1);
Pntr=Pntr.FrstMbr;
for(i;i;i--)Pntr=Pntr.PrvMbr;
if(Nav4)Pntr.CLyr.OM();
else Pntr.OM();
Pntr=Pntr.CCn}
i=Pntr.NrItms-parseInt(Str);
Pntr=Pntr.FrstMbr;
for(i;i;i--)Pntr=Pntr.PrvMbr;
if(RmbrNow!=null){SetItem(RmbrNow,0);RmbrNow.Clckd=0}
if(Pntr!=null){SetItem(Pntr,1);Pntr.Clckd=1;
if(RememberStatus==1){if(Nav4)Pntr.CLyr.OM();else Pntr.OM()}}
RmbrNow=Pntr;
ClrAllChlds(FrstCntnr.FrstMbr);
Rmbr(FrstCntnr)}
function Initiate(){
if(IniFlg&&Ldd){Init(FrstCntnr);IniFlg=0;if(RememberStatus)Rmbr(FrstCntnr);if(ShwFlg)AfterCloseAll();ShwFlg=0}}
function Rmbr(CntPtr){
var Mbr=CntPtr.FrstMbr,St;
while(Mbr!=null){
if(Mbr.DoRmbr){
HiliteItem(Mbr);
if(Mbr.CCn&&RememberStatus==1){St=Nav4?Mbr.CCn:Mbr.CCn.style;St.visibility=M_Show;Rmbr(Mbr.CCn)}
break}
else Mbr=Mbr.PrvMbr}}
function Init(CPt){
var Mb=CPt.FrstMbr,MCSt=Nav4?CPt:CPt.style;
RLvl++;MCSt.visibility=RLvl==1?M_Show:M_Hide;CPt.Shw=RLvl==1?1:0;
while(Mb!=null){if(Mb.Hilite)LowItem(Mb);if(Mb.CCn)Init(Mb.CCn);Mb=Mb.PrvMbr}
RLvl--}
function ClrAllChlds(Pt){
var PSt,Pc;
while(Pt){if(Pt.Hilite){Pc=Nav4?Pt.CLyr:Pt;if(Pc!=CurOvr){LowItem(Pt)}
if(Pt.CCn){PSt=Nav4?Pt.CCn:Pt.CCn.style;if(Pc!=CurOvr){PSt.visibility=M_Hide;Pt.CCn.Shw=0}ClrAllChlds(Pt.CCn.FrstMbr)}
break}
Pt=Pt.PrvMbr}}
function SetItem(Pntr,x){while(Pntr!=null){Pntr.DoRmbr=x;Pntr=Nav4?Pntr.CLyr.Ctnr.Cllr:Pntr.Ctnr.Cllr}}
function GoTo(){
var HP=Nav4?this.LLyr:this;
if(HP.Arr[1]){status="";LowItem(HP);IniFlg=1;Initiate();
HP.Arr[1].indexOf("javascript:")!=-1?eval(HP.Arr[1]):DcLoc.location.href=BaseHref+HP.Arr[1]}}
function HiliteItem(P){
if(Nav4){ if(P.ro)P.document.images[P.rid].src=P.ri2;
else{
P.bgColor = HighBgColor;
if(P.value.indexOf("<img")==-1){P.document.write(P.Ovalue);P.document.close()}}}
else{
if(P.ro){var Lc=P.Lvl==1?FLoc:ScLoc;Lc.document.images[P.rid].src=P.ri2}
else{
P.style.backgroundColor=HighBgColor;
P.style.color=FontHighColor;
P.Hilite=1
function LowItem(P){
P.Hilite=0;
if(P.ro){if(Nav4)P.document.images[P.rid].src=P.ri1;
else{var Lc=P.Lvl==1?FLoc:ScLoc;Lc.document.images[P.rid].src=P.ri1}}
else{
if(Nav4){
P.bgColor=LowBgColor;
if(P.value.indexOf("<img")==-1){P.document.write(P.value);P.document.close()}}
else{
P.style.backgroundColor=LowBgColor;
P.style.color=FontLowColor;
function OpenMenu(){
if(!Ldd||!Crtd)return;
if(OpnTmr)clearTimeout(OpnTmr);
var P=Nav4?this.LLyr:this;
if(P.NofChlds&&!P.CCn){
RLvl=this.Lvl;
P.CCn=CreateMenuStructure(P.MN+"_",P.NofChlds,P);
var Ti,Li,Hi;
var MStl=!Nav4?P.style:P;
var PadL=P.value.indexOf("<")==-1?LftXtra:0;
var PadT=P.value.indexOf("<")==-1?TpXtra:0;
var MWt=!Nav4?parseInt(MStl.width)+PadL:MStl.clip.width;
var MHt=!Nav4?parseInt(MStl.height)+PadT:MStl.clip.height;
var CCw,CCh,STp,SLt;
var BRW=RLvl==1?BorderWidthMain:BorderWidthSub;
if(RightToLeft)CCw=Nav4?P.CCn.clip.width:parseInt(P.CCn.style.width);
if(BottomUp)CCh=Nav4?P.CCn.clip.height:parseInt(P.CCn.style.height);
if(RLvl==1&&FirstLineHorizontal){Hi=1;Li=(Nav4?P.left:parseInt(P.style.left))-BRW;Ti=0}
else{Hi=Li=0;Ti=(Nav4?P.top:parseInt(P.style.top))-BRW}
if(Hi){STp=BottomUp?Ti-CCh:Ti+MHt+2*BRW;SLt=RightToLeft?Li+MWt-CCw:Li}
else{SLt=RightToLeft?Li-CCw+ChildOverlap*MWt+BRW:Li+(1-ChildOverlap)*MWt;
STp=RLvl==1&&AcrssFrms?BottomUp?Ti-CCh+MHt:Ti:BottomUp?Ti-CCh+(1-ChildVerticalOverlap)*MHt+2*BRW:Ti+ChildVerticalOverlap*MHt+BRW}
PosMenu(P.CCn,STp,SLt);
RLvl=0}
var CCnt=Nav4?this.LLyr.CCn:this.CCn,HP=Nav4?this.LLyr:this;
CurOvr=this;IniFlg=0;ClrAllChlds(this.Ctnr.FrstMbr);
if(!HP.Hilite)HiliteItem(HP);
if(CCnt!=null&&!CCnt.Shw)RememberStatus?Unfld():OpnTmr=setTimeout("Unfld()",UnfoldDelay);
//alert(HP.value);
status=HP.value;
function Unfld(){
var P=CurOvr;
var TS=ExpYes?ScLoc.document.body.scrollTop:ScLoc.pageYOffset,LS=ExpYes?ScLoc.document.body.scrollLeft:ScLoc.pageXOffset,CCnt=Nav4?P.LLyr.CCn:P.CCn,THt=Nav4?P.clip.height:parseInt(P.style.height),TWt=Nav4?P.clip.width:parseInt(P.style.width),TLt=AcrssFrms&&P.Lvl==1&&!FirstLineHorizontal?0:Nav4?P.Ctnr.left:parseInt(P.Ctnr.style.left),TTp=AcrssFrms&&P.Lvl==1&&FirstLineHorizontal?0:Nav4?P.Ctnr.top:parseInt(P.Ctnr.style.top);
// TS != 0 is only needed if the menu DIVs are positioned relative to the body.
// We've made them positioned relative to div#navigationMenu which causes
// a problem if TS is based on how the body is scrolled. So set TS to zero.
// Note: the code below will adjust the final top offset based on the height of
// the menu bar so the dropdown appears below (and not on top of) the nav bar.
TS = 0;
var CCW=Nav4?P.LLyr.CCn.clip.width:parseInt(P.CCn.style.width),CCH=Nav4?P.LLyr.CCn.clip.height:parseInt(P.CCn.style.height),CCSt=Nav4?P.LLyr.CCn:P.CCn.style,SLt=AcrssFrms&&P.Lvl==1?CCnt.OrgLeft+TLt+LS:CCnt.OrgLeft+TLt,STp=AcrssFrms&&P.Lvl==1?CCnt.OrgTop+TTp+TS:CCnt.OrgTop+TTp;
if(!ShwFlg){ShwFlg=1;BeforeFirstOpen()}
if(MenuWrap){
if(RightToLeft){if(SLt<LS)SLt=P.Lvl==1?LS:SLt+(CCW+(1-2*ChildOverlap)*TWt);if(SLt+CCW>SWinW+LS)SLt=SWinW+LS-CCW}
else{if(SLt+CCW>SWinW+LS)SLt=P.Lvl==1?SWinW+LS-CCW:SLt-(CCW+(1-2*ChildOverlap)*TWt);if(SLt<LS)SLt=LS}
if(BottomUp){if(STp<TS)STp=P.Lvl==1?TS:STp+(CCH-(1-2*ChildVerticalOverlap)*THt);if(STp+CCH>SWinH+TS)STp=SWinH+TS-CCH+(Nav4?4:0)}
else{if(STp+CCH>TS+SWinH)STp=P.Lvl==1?STp=TS+SWinH-CCH:STp-CCH+(1-2*ChildVerticalOverlap)*THt;if(STp<TS)STp=TS}}
CCSt.top=STp+P_X;CCSt.left=SLt+P_X;
if(Fltr&&MenuSlide){P.CCn.filters[0].Apply();P.CCn.filters[0].play()}
CCSt.visibility=M_Show}
function OpenMenuClick(){
if(!Ldd||!Crtd)return;
var HP=Nav4?this.LLyr:this;CurOvr=this;
IniFlg=0;ClrAllChlds(this.Ctnr.FrstMbr);HiliteItem(HP);
function CloseMenu(){
if(!Ldd||!Crtd)return;
status="";
if(this==CurOvr){if(OpnTmr)clearTimeout(OpnTmr);if(CloseTmr)clearTimeout(CloseTmr);IniFlg=1;CloseTmr=setTimeout("Initiate(CurOvr)",DissapearDelay)}}
function CntnrSetUp(W,H,NoOff,WMu,Mc){
var x=BorderColor;
this.FrstMbr=null;this.NrItms=NoOff;this.Cllr=Mc;this.Shw=0;
this.OrgLeft=this.OrgTop=0;
if(Nav4){if(x)this.bgColor=x;this.visibility="hide";this.resizeTo(W,H)}
else{if(x)this.style.backgroundColor=x;this.style.width=W+P_X;this.style.height=H+P_X;
if(!NavYes)this.style.zIndex=RLvl+Ztop;
if(Fltr){FStr="";if(MenuSlide&&RLvl!=1)FStr=MenuSlide;if(MenuShadow)FStr+=MenuShadow;
if(MenuOpacity)FStr+=MenuOpacity;if(FStr!="")this.style.filter=FStr}}}
function MbrSetUp(MbC,PrMmbr,WMu,Wd,Ht,Nofs){
var Lctn=RLvl==1?FLoc:ScLoc,Tfld=this.Arr[0],t,T,L,W,H,S,a;
this.PrvMbr=PrMmbr;this.Lvl=RLvl;this.Ctnr=MbC;this.CCn=null;this.ai=null;this.Hilite=0;this.DoRmbr=0;
this.Clckd=0;this.OM=OpenMenu;this.style.overflow="hidden";
this.MN=WMu;this.NofChlds=Nofs;
this.style.cursor=(this.Arr[1]||(RLvl==1&&UnfoldsOnClick))?ExpYes?"hand":"pointer":"default";this.ro=0;
if(Tfld.indexOf("rollover")!=-1){this.ro=1;this.ri1=Tfld.substring(Tfld.indexOf("?")+1,Tfld.lastIndexOf("?"));
this.ri2=Tfld.substring(Tfld.lastIndexOf("?")+1,Tfld.length);this.rid=WMu+"i";
Tfld="<img src=\""+this.ri1+"\" name=\""+this.rid+"\" width=\""+Wd+"\" height=\""+Ht+"\">"}
this.value=Tfld;
this.style.color=FontLowColor;
this.style.fontFamily=FontFamily;
this.style.fontSize = FontSize + "pt";
this.style.fontWeight="normal";
this.style.fontStyle="normal";
this.style.backgroundColor=LowBgColor;
if (WMu.length > 6)
{ MenuTextCentered = 'left';}
else
{MenuTextCentered = 'center';}
this.style.textAlign=MenuTextCentered;
if(this.Arr[2])this.style.backgroundImage="url(\""+this.Arr[2]+"\")";
if(Tfld.indexOf("<")==-1){this.style.width=Wd-LftXtra+P_X;this.style.height=Ht-TpXtra+P_X;this.style.paddingLeft=LeftPaddng+P_X;this.style.paddingTop=TopPaddng+P_X}
else{this.style.width=Wd+P_X;this.style.height=Ht+P_X}
if(Tfld.indexOf("<")==-1&&DomYes){t=Lctn.document.createTextNode(Tfld);this.appendChild(t)}
else this.innerHTML=Tfld;
if(this.Arr[3]){a=RLvl==1&&FirstLineHorizontal?BottomUp?9:3:RightToLeft?6:0;
if(Arrws[a]!=""){S=Arrws[a];W=Arrws[a+1];H=Arrws[a+2];T=RLvl==1&&FirstLineHorizontal?BottomUp?2:Ht-H-2:(Ht-H)/2;L=RightToLeft?2:Wd-W-2;
if(DomYes){t=Lctn.document.createElement("img");this.appendChild(t);
t.style.position="absolute";t.src=S;t.style.width=W+P_X;t.style.height=H+P_X;t.style.top=T+P_X;t.style.left=L+P_X}
else{Tfld+="<div id=\""+WMu+"_im\" style=\"position:absolute; top:"+T+"; left:"+L+"; width:"+W+"; height:"+H+";visibility:inherit\"><img src=\""+S+"\"></div>";
this.innerHTML=Tfld;t=Lctn.document.all[WMu+"_im"]}
this.ai=t}}
if(ExpYes){this.onselectstart=CnclSlct;this.onmouseover=RLvl==1&&UnfoldsOnClick?OpenMenuClick:OpenMenu;
this.onmouseout=CloseMenu;this.onclick=RLvl==1&&UnfoldsOnClick&&this.Arr[3]?OpenMenu:GoTo}
else{RLvl==1&&UnfoldsOnClick?this.addEventListener("mouseover",OpenMenuClick,false):this.addEventListener("mouseover",OpenMenu,false);
this.addEventListener("mouseout",CloseMenu,false);
RLvl==1&&UnfoldsOnClick&&this.Arr[3]?this.addEventListener("click",OpenMenu,false):this.addEventListener("click",GoTo,false)}}
function NavMbrSetUp(MbC,PrMmbr,WMu,Wd,Ht,Nofs){
var a;
this.value=this.Arr[0];this.ro=0;
if(this.value.indexOf("rollover")!=-1){
this.ro=1;this.ri1=this.value.substring(this.value.indexOf("?")+1,this.value.lastIndexOf("?"));
this.ri2=this.value.substring(this.value.lastIndexOf("?")+1,this.value.length);this.rid=WMu+"i";
this.value="<img src=\""+this.ri1+"\" name=\""+this.rid+"\">"}
CntrTxt="<div align=\""+MenuTextCentered+"\">";
TxtClose="</font>"+ "</div>";
if(LeftPaddng&&this.value.indexOf("<")==-1&&MenuTextCentered=="left")this.value="�\;"+this.value;
this.Ovalue=this.value;
this.value=this.value.fontcolor(FontLowColor);
this.Ovalue=this.Ovalue.fontcolor(FontHighColor);
this.value=CntrTxt+"<font face=\""+FontFamily+"\" point-size=\""+FontSize+"\">"+this.value+TxtClose;
this.Ovalue=CntrTxt+"<font face=\""+FontFamily+"\" point-size=\""+FontSize+"\">"+this.Ovalue+TxtClose;
this.CCn=null;this.PrvMbr=PrMmbr;this.Hilite=0;this.DoRmbr=0;this.Clckd=0;this.visibility="inherit";
this.MN=WMu;this.NofChlds=Nofs;
this.bgColor=LowBgColor;
this.resizeTo(Wd,Ht);
if(!AcrssFrms&&this.Arr[2])this.background.src=this.Arr[2];
this.document.write(this.value);this.document.close();
this.CLyr=new Layer(Wd,MbC);
this.CLyr.Lvl=RLvl;this.CLyr.visibility="inherit";
this.CLyr.onmouseover=RLvl==1&&UnfoldsOnClick?OpenMenuClick:OpenMenu;this.CLyr.onmouseout=CloseMenu;
this.CLyr.captureEvents(Event.MOUSEUP);this.CLyr.onmouseup=RLvl==1&&UnfoldsOnClick&&this.Arr[3]?OpenMenu:GoTo;
this.CLyr.OM=OpenMenu;
this.CLyr.LLyr=this;this.CLyr.resizeTo(Wd,Ht);this.CLyr.Ctnr=MbC;
if(this.Arr[3]){a=RLvl==1&&FirstLineHorizontal?BottomUp?9:3:RightToLeft?6:0;
if(Arrws[a]!=""){this.CLyr.ILyr=new Layer(Arrws[a+1],this.CLyr);this.CLyr.ILyr.visibility="inherit";
this.CLyr.ILyr.top=RLvl==1&&FirstLineHorizontal?BottomUp?2:Ht-Arrws[a+2]-2:(Ht-Arrws[a+2])/2;
this.CLyr.ILyr.left=RightToLeft?2:Wd-Arrws[a+1]-2;this.CLyr.ILyr.width=Arrws[a+1];this.CLyr.ILyr.height=Arrws[a+2];
ImgStr="<img src=\""+Arrws[a]+"\" width=\""+Arrws[a+1]+"\" height=\""+Arrws[a+2]+"\">";
this.CLyr.ILyr.document.write(ImgStr);this.CLyr.ILyr.document.close()}}}
function CreateMenuStructure(MNm,No,Mcllr){
status="Building menu";RLvl++;
var i,NOs,Mbr,W=0,H=0,PMb=null,WMnu=MNm+"1",MWd=eval(WMnu+"[5]"),MHt=eval(WMnu+"[4]"),Lctn=RLvl==1?FLoc:ScLoc;
var BRW=RLvl==1?BorderWidthMain:BorderWidthSub,BTWn=RLvl==1?BorderBtwnMain:BorderBtwnSub;
if(RLvl==1&&FirstLineHorizontal){
for(i=1;i<No+1;i++){WMnu=MNm+eval(i);W=eval(WMnu+"[5]")?W+eval(WMnu+"[5]"):W+MWd}
W=BTWn?W+(No+1)*BRW:W+2*BRW;H=MHt+2*BRW}
else{for(i=1;i<No+1;i++){WMnu=MNm+eval(i);H=eval(WMnu+"[4]")?H+eval(WMnu+"[4]"):H+MHt}
H=BTWn?H+(No+1)*BRW:H+2*BRW;W=MWd+2*BRW}
if(DomYes){var MbC=Lctn.document.createElement("div");MbC.style.position="absolute";MbC.style.visibility="hidden";Lctn.document.getElementById("navigationMenu").appendChild(MbC)}
else{if(Nav4)var MbC=new Layer(W,Lctn);
else{WMnu+="c";Lctn.document.body.insertAdjacentHTML("AfterBegin","<div id=\""+WMnu+"\" style=\"visibility:hidden; position:absolute;\"><\/div>");
var MbC=Lctn.document.all[WMnu]}}
MbC.SetUp=CntnrSetUp;MbC.SetUp(W,H,No,MNm+"1",Mcllr);
if(Exp4){MbC.InnerString="";
for(i=1;i<No+1;i++){WMnu=MNm+eval(i);MbC.InnerString+="<div id=\""+WMnu+"\" style=\"position:absolute;\"><\/div>"}
MbC.innerHTML=MbC.InnerString}
for(i=1;i<No+1;i++){WMnu=MNm+eval(i);NOs=eval(WMnu+"[3]");
W=RLvl==1&&FirstLineHorizontal?eval(WMnu+"[5]")?eval(WMnu+"[5]"):MWd:MWd;
H=RLvl==1&&FirstLineHorizontal?MHt:eval(WMnu+"[4]")?eval(WMnu+"[4]"):MHt;
if(DomYes){Mbr=Lctn.document.createElement("div"); Mbr.style.position="absolute";Mbr.style.visibility="inherit";MbC.appendChild(Mbr)}
else Mbr=Nav4?new Layer(W,MbC):Lctn.document.all[WMnu];
Mbr.Arr=eval(WMnu);
Mbr.SetUp=Nav4?NavMbrSetUp:MbrSetUp;Mbr.SetUp(MbC,PMb,WMnu,W,H,NOs);
if(NOs&&!BuildOnDemand){Mbr.CCn=CreateMenuStructure(WMnu+"_",NOs,Mbr)}
PMb=Mbr}
MbC.FrstMbr=Mbr;
RLvl--;
return(MbC)}
function CreateMenuStructureAgain(MNm,No){
if(!BuildOnDemand){
var i,WMnu,NOs,PMb,Mbr=FrstCntnr.FrstMbr;RLvl++;
for(i=No;i>0;i--){WMnu=MNm+eval(i);NOs=eval(WMnu+"[3]");PMb=Mbr;if(NOs)Mbr.CCn=CreateMenuStructure(WMnu+"_",NOs,Mbr);Mbr=Mbr.PrvMbr}
RLvl--}
else{ var Mbr=FrstCntnr.FrstMbr;
while(Mbr){Mbr.CCn=null;Mbr=Mbr.PrvMbr}}}Hi thanks...As you said I am performing only on onload event..only thing i am confused is if i remove the javacript MRHeader.js everything works fine...am totally confused...pls help
Here is my JSP code for my input page
<%@page import="java.util.*" %>
<%@page import="com.ford.mr.*" %>
<HTML>
<HEAD>
<link href="./css/mplstyle.css" rel="STYLESHEET" type="text/css">
<title>Input Frame</title>
<link type="text/css" rel="STYLESHEET" href="./css/classic.css">
<STYLE>
.vis1 { visibility:visible }
.vis2 { visibility:hidden }
</STYLE>
<%--
MRIFValidation.js contains the java script for the following requirement:
1. Setting the current date in date to compare
2. All input frame client validations.
E.g Plant id should not be empty.
--%>
<script type="text/javascript" src="./javascript/MRIFValidation.js"> </script>
<%--
MRR2HandleDropdown.js is the javascript for the input frame server side actions
It has many functions related to drop down populating and rendering the data
to user from server.
--%>
<script language="javascript" src="./javascript/MRR2HandleDropdown.js"> </script>
<%--
MRheader.js is the javascript which displays the header for our application
plus it has an internal call to MRMenuItem.js and menuscript.js which
builds the menu bar for our application
Issue is here - On commenting the below the previously entered user
inputs are displayed correctly. Else they are not displayed.
--%>
<script language="javascript" src="./javascript/MRheader.js"> </script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
a:visited {
color: #0000FF;
.style1 {font-weight: bold}
.style2 {color: #FF0000}
body {
background-color: #FFFFFF;
-->
</style>
<%--
Declaring all the JSP variables used in the page
These variables are used for holding the session parameters
and are used while setting the selected values in the screen.
--%>
<%!
// HTTPSession object
HttpSession sess;
// To hold session Variables //
// Selected plant index
String plantIndex;
// Selected supplier index
String supplierIndex;
// Selected part index
String partIndex;
// List of plant codes
Vector plantCodes = new Vector();
// List of supplier codes
Vector supplierCodes = new Vector();
// List of part codes
Vector partCodes = new Vector();
// To hold the part description for the selected part
String partDescription;
// List of release numbers matching the selected plant, supplier & part
Vector releaseNumbers = new Vector();
// Type of release - Weekly / Daily
String releaseType;
// Selected release1 index
String release1Index;
// Selected release2 index
String release2Index;
// Holds the issue date 1 corresponding to release 1 selected
String issueDate1;
// Holds the issue date 2 corresponding to release 2 selected
String issueDate2;
// List of matching release numbers to the entered issue date1 (Might be one or two
// in case if amended release exist)
Vector matchingRelease1Number = new Vector();
// List of matching release numbers to the entered issue date2 (Might be one or two
// in case if amended release exist)
Vector matchingRelease2Number = new Vector();
// Size of matchingRelease1Number collection
int matchingRelease1Size = 0;
// Size of matchingRelease2Number collection
int matchingRelease2Size = 0;
// Boolean flags to hold if amended release exists in the release numbers
// matching the issue dates entered by user.
boolean amendedRelease1Exist;
boolean amendedRelease2Exist;
String pageName = "";
%>
<%--
The below code does the following:
1. Fetches the various values available in session
2. Stores the same in various JSP variables for access within the page
--%>
<%
System.out.println("In input frame page");
sess = request.getSession(true);
if(sess != null) {
System.out.println("Session id in input frame: "+ sess.getId());
plantIndex = (String) sess.getAttribute("selectedPlantIndex");
supplierIndex = (String) sess.getAttribute("selectedSupplierIndex");
partIndex = (String) sess.getAttribute("selectedPartIndex");
//plantCodes = (Vector) sess.getAttribute("plantCodes");
supplierCodes = (Vector) sess.getAttribute("supplierCodes");
partCodes = (Vector) sess.getAttribute("partCodes");
partDescription = (String) sess.getAttribute("partDescription");
releaseNumbers = (Vector) sess.getAttribute("releaseNumbers");
releaseType = (String) sess.getAttribute("releaseType");
release1Index = (String) sess.getAttribute("selectedRelease1Index");
release2Index =(String) sess.getAttribute("selectedRelease2Index");
issueDate1 = (String) sess.getAttribute("issueDate1");
issueDate2 = (String) sess.getAttribute("issueDate2");
matchingRelease1Number = (Vector) sess.getAttribute("correspondingRelease1Number");
matchingRelease2Number = (Vector) sess.getAttribute("correspondingRelease2Number");
System.out.println("Displaying values in session *******************");
Enumeration enum = sess.getAttributeNames();
while(enum.hasMoreElements()) {
String elementName = (String) enum.nextElement();
System.out.println("element:"+ elementName+": Value: "+ sess.getAttribute(elementName));
System.out.println("Plant Index JSP variable:"+ plantIndex);
%>
<%--
This code is used for getting the plant codes from
the DB. Currently it is hardcoded.
--%>
<%
MRR2GetPlantCodes obj = new MRR2GetPlantCodes();
plantCodes = obj.getPlantCodes();
%>
<%--
The below two blocks are used to iterate through matchingRelease1Number & matchingRelease2Number
and checks if it has amended release. If yes, sets a boolean flag.
matchingRelease1Number & matchingRelease2Number are two collections which
contains the release number(s) matching the inputted issue date
--%>
<%
// Code to set boolean flag amendedRelease1Exist
if(matchingRelease1Number != null) {
Iterator relIter = matchingRelease1Number.iterator();
while(relIter.hasNext()) {
if( ((String)relIter.next()).endsWith("A") ) {
amendedRelease1Exist = true;
// Code to set boolean flag amendedRelease2Exist
if(matchingRelease2Number != null) {
Iterator relIter = matchingRelease2Number.iterator();
while(relIter.hasNext()) {
if( ((String)relIter.next()).endsWith("A") ) {
amendedRelease2Exist = true;
%>
<%--
The below script has one method fillDropDown which is used for setting the
values of the various I/P controls to user selected values:
It sets the below selected values:
1. Plant Index, Supplier Index, Part Index, Part description
2. Release Type (Daily / weekly)
3. Release 1 Index, Release 2 Index
4. Issue date1 & Issue date2
--%>
<script language="javascript">
function fillDropDown(field) {
with(field) {
var partD = "<%=partDescription%>"
<% System.out.println("Loading the index values in input frame......");%>
// inputform.country.selectedIndex = inputform.hiddencountry.value
// Loading plant Index, supplier Index, part index and part description to selected values
<% if(plantIndex != null && !plantIndex.equals("")) {%>
inputframe.plant.selectedIndex = "<%=Integer.parseInt(plantIndex)%>"
<% System.out.println("Selected Plant Index after loading:"+plantIndex);} %>
<% if(supplierIndex != null && !supplierIndex.equals("")) { System.out.println("****Supplier Index not equals null..."+Integer.parseInt(supplierIndex)); %>
inputframe.supplier.selectedIndex = "<%=Integer.parseInt(supplierIndex)%>"
<% } %>
<% if(partIndex != null && !partIndex.equals("")) { %>
inputframe.part.selectedIndex = "<%=Integer.parseInt(partIndex)%>"
<% } %>
<% if(partDescription != null && !partDescription.equals("")) { %>
document.getElementById("partDescription").innerHTML = partD
<% } %>
// Making the default release type selection as done by user
<% if(releaseType != null && !"".equals(releaseType)) {
if("daily".equals(releaseType)) {%>
inputframe.release[0].checked = "checked"
<% //isDaily = true;
} else { %>
inputframe.release[1].checked = "checked"
<% //isWeekly = true;
} %>
<%--
The below code is used to fetch the session variable issueDate1
& issueDate2 (based on the release numbers selected)
and sets the same in two text fields.
--%>
<% if(issueDate1 != null && !issueDate1.equals("")) { %>
inputframe.issueDate1.value = "<%=issueDate1%>"
<% } %>
<% if(issueDate2 != null && !issueDate2.equals("")) { %>
inputframe.issueDate2.value = "<%=issueDate2%>"
<% } %>
<%--
Loading release drop down with the value matching with the entered issue date.
Scenario : User enters the issue date and the corresponding release number is
selected in drop down.
Logic 1:
1. Pass the issue date entered by user and get the matching release numbers
from EJB
2. Compare this with the combo collection and get the perfect match.
3. If more than one match is found take the one with amendment by default
4. Else get the matching one
5. Update the selected index of dropdown to this value
--%>
if(inputframe.release1.options.length > 0) {
var matchingCombo1Index = 0
var comboValue
var matchFound = "false"
var size
var amended = false;
var amendedReleaseExist = "<%=amendedRelease1Exist%>";
var firstValue = ""
var secondValue = ""
var amendedValue = ""
var j = 0
<%
if(matchingRelease1Number != null && matchingRelease1Number.size() != 0) {
Iterator iter = matchingRelease1Number.iterator();
matchingRelease1Size = matchingRelease1Number.size(); %>
size = "<%= matchingRelease1Size %>"
//alert("Size of collection to be matched:"+size)
<% while(iter.hasNext()) {
//String matchFound1 = "false";
String relValue = (String)iter.next();%>
//alert("Collection value under iteration:"+ "<%=relValue%>")
amended = "<%=relValue.endsWith("A")%>"
if(amended) {
amendedValue = "<%=relValue%>"
//alert("Collection value under iteration ends with A:"+amended)
var comb = "<%=relValue%>"
j = j + 1
for(var i = 0; i < inputframe.release1.options.length; i++) {
// breaking the for loop when matchingCombo1Index is set greater than 0
/*if(matchFound == true) {
break
comboValue = inputframe.release1.options.value
//alert("Combo value:->"+comboValue)
//alert("rel value in comparison:"+ comb);
if(comboValue == comb) {
if(size == 1) {
matchFound = "true";
if(size == 2) {
if(j == 1)
firstValue = comb
if(j == 2)
secondValue = comb
// The below if block shall be also kept as if((amended||(!amendedReleaseExist)==true)
// The below one perfectly works fine
if(amended || !amendedReleaseExist) {
matchFound = "true";
if(matchFound == "true") {
matchingCombo1Index = i
// alert("Matching combo index set to:"+ matchingCombo1Index)
inputframe.release1.selectedIndex = matchingCombo1Index
if(size == 2)
document.getElementById('errorArea').innerHTML = "There are"
+ " two release numbers for the particular Issue date."
+" Please select either one of the release numbers ("+firstValue+ " or "+secondValue+" )."
+" Default selection in the Release drop down is "+ amendedValue+ "."
matchingCombo1Index = 0;
matchFound = "false";
// Breaking the for loop
break;
<%
sess.removeAttribute("correspondingRelease1Number") ;
}%>
// Setting the selected release 1 index based on the logic done above.
if(matchingCombo1Index == 0) {
<% if(release1Index != null && !release1Index.equals("")) { matchingRelease1Number = null;%>
inputframe.release1.selectedIndex = "<%=Integer.parseInt(release1Index)%>"
<% } %>
<%--
Performing the above logic to select Release2 value
when the user enters issue date2
--%>
if(inputframe.release2.options.length > 0) {
var matchingCombo2Index = 0
var comboValue
var matchFound = "false"
var size
var amended = false;
var amendedReleaseExist = "<%=amendedRelease2Exist%>";
var firstValue = ""
var secondValue = ""
var amendedValue = ""
var j = 0
<%
if(matchingRelease2Number != null && matchingRelease2Number.size() != 0) {
Iterator iter = matchingRelease2Number.iterator();
matchingRelease2Size = matchingRelease2Number.size(); %>
size = "<%= matchingRelease2Size %>"
//alert("Size of collection to be matched:"+size)
<% while(iter.hasNext()) {
String matchFound1 = "false";
String relValue = (String)iter.next();%>
//alert("Collection value under iteration:"+ "<%=relValue%>")
amended = "<%=relValue.endsWith("A")%>"
if(amended) {
amendedValue = "<%=relValue%>"
//alert("Collection value under iteration ends with A:"+amended)
var comb = "<%=relValue%>"
j = j + 1
for(var i = 0; i < inputframe.release2.options.length; i++) {
// breaking the for loop when matchingCombo2Index is set greater than 0
/*if(matchFound == true) {
break
comboValue = inputframe.release2.options[i].value
//alert("Combo value:->"+comboValue)
//alert("rel value in comparison:"+ comb);
if(comboValue == comb) {
if(size == 1) {
matchFound = "true";
if(size == 2) {
if(j == 1)
firstValue = comb
if(j == 2)
secondValue = comb
// The below if block shall be also kept as if((amended||(!amendedReleaseExist)==true)
// The below one perfectly works fine
if(amended || !amendedRelease2Exist) {
matchFound = "true";
if(matchFound == "true") {
matchingCombo2Index = i
// alert("Matching combo index set to:"+ matchingCombo2Index)
inputframe.release2.selectedIndex = matchingCombo2Index
if(size == 2)
document.getElementById('errorArea').innerHTML = "There are"
+ " two release numbers for the particular Issue date."
+" Please select either one of the release numbers ("+firstValue+ " or "+secondValue+" )."
+" Default selection in the Release drop down is "+ amendedValue+ "."
matchingCombo2Index = 0;
matchFound = "false";
// Breaking the for loop
break;
<%
sess.removeAttribute("correspondingRelease2Number") ;
}%>
// Loading the selected release2 value in drop down
if(matchingCombo2Index == 0) {
<% if(release2Index != null && !release2Index.equals("")) { matchingRelease2Number = null;%>
inputframe.release2.selectedIndex = "<%=Integer.parseInt(release2Index)%>"
<% } %>
} // end of WITH
Logic 2: Not used
1. Pass the issue date entered by user and get the matching release numbers
2. Get the release numbers from session.
3. if release type is daily get the daily release numbers else get weekly release numbers
4. Compare the matching release numbers with daily / weekly release numbers collection
5. Find the match and update the selected index of drop down to this value
}// end of function
</script>
</HEAD>
<%-- Calling the two methods onload event of body --%>
<BODY onload="setCurrentDate(this);fillDropDown(this)"> -
GetParameter, setAttribute and session values
I am having a problem forwarding values to a jsp from my servlet.
This problem only occurs when multiple users are accessing the same pages to make a payment.
The value is passed from the page to the servlet.
The servlet gets the value using a getParameter.
//Get the value from the previous page
String DocTotal = request.getParameter("DocTotal");
logger.debug("DocTotal: " + DocTotal);
//set the value to pass to next page
request.setAttribute("payAmount", DocTotal);
displayTemplate(CREDITCARDPAYMENT);
displayTemplate code follows.
RequestDispatcher rd = getServletContext().getRequestDispatcher(template);
rd.forward(req, res);
I then set the value in the request object to pass to the next page.
This all seems to work fine for a single user but when I I have more than one user, one user will get a null for value being passed on the next page and the other user will not get the page displayed.
It is like my session values are getting stomped on by the other user.The changes that you have suggested seem to work, but I still have a problem.
One user seems to be able to get the data passed successfully to the next jsp, but the other just gets a blank screen. If the user with the blank screen refreshes they get the screen with the data. It is as if the servlet hangs up when calling the page. I am not sure.
Here is the code that is being accessed with formatting.
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
req = request;
res = response;
HttpSession session = req.getSession(true);
logger.debug("Made it to the doPost method of DownloadUtilServlet!");
logger.debug("session: " + session);
String cmd = req.getParameter("cmd");
logger.debug("cmd equals: " + cmd);
if ((cmd != null) && cmd.equalsIgnoreCase("forwardPaymentInfo")){
XCBillerCenterItem bci = null;
try{
logger.debug("XCConfig.CCUSER: " + XCConfig.CCUSER);
bci = new XCBillerCenterItem(XCConfig.CCUSER);
catch(Exception e) {
logger.debug("XCBillerCenterItem Create: " + e);
String ccList = bci.getCCTypes();
req.setAttribute("ccList", ccList);
logger.debug("cmd equals: " + cmd);
String DocTotal = req.getParameter("DocTotal");
logger.debug("DocTotal: " + DocTotal);
req.setAttribute("payAmount", DocTotal);
displayTemplate(CREDITCARDPAYMENT);
}//User has paid, proceed to download
else if ((cmd != null) && cmd.equalsIgnoreCase("downloadreportfilter")){
displayTemplate(DOWNLOADREPORTFILTER);
else{
GetParameters(req, res, session);
public void displayTemplate(String template)
try
RequestDispatcher rd = getServletContext().getRequestDispatcher(template);
rd.forward(req, res);
catch(Exception e)
e.printStackTrace();
Maybe you are looking for
-
Installing Bootcamp 3.0 drivers
Could anyone explain why I'm getting the message "Bootcamp x64 cannot run on this computer and model" when I'm running x64 Windows 7 on a x64 Macbook?
-
How to Disconnect ID CS6 from Creative Cloud
When I installed Creative Cloud, it replaced my Adobe Application Manager, and took over management of my ID CS6. Now my CC subscription has expired. When I try to launch ID CS6, a message appears saying my CC subscription has expired, and I need to
-
Keynote for iOS file size: inserting photos from Mac first or from iPad?
Hi! This one is for people with advanced and extensive knowledge of Keynote for Mac and for iOS: Does inserting pictures in Keynote for iOS from the Photos app result in a leaner file size than importing the Keynote file with pictures already inserte
-
How to display custom images on a Page..?
Hi Guys, I have developed a application for my company, everything is working fine.., but on the Home Page of the application i want to display my company LOGO image. I have uploaded the images in the shared components -->Files --> Images but how to
-
I need to access my "collected Addresses", but when I open the addressbook, it only shows my "Personalbook", which is "empty. How to change to my "Collected addressbook?