GetLastModified() not working in JSP

i have overridden getLastModified() from HttpServlet in my JSP page,
but it is never called. please help.
<%!
public long getLastModified(HttpServletRequest req)
     Date d = new Date();
     long lng = d.getTime();
     System.out.println("Inside getLastModified() : " +d);
     return lng;
%>

i am using "Apache Tomcat/5.0.28"
and all jsp are converted to servlet which extends org.apache.jasper.runtime.HttpJspBase which in turn extends javax.servlet.http.HttpServlet
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jasper/docs/api/org/apache/jasper/runtime/HttpJspBase.html
as my jsp (automatically converted servlet) is extending javax.servlet.http.HttpServlet, now i think getLastModified() should definitely get called.
one more thing i found is that when i override getLastModified() with int as return type, i am getting transalation time error as follow :
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 30 in the jsp file: /core.jsp
Generated servlet error:
D:\hasan\jakarta-tomcat-5028\work\Catalina\localhost\test\org\apache\jsp\core_jsp.java:12: getLastModified(javax.servlet.http.HttpServletRequest) in org.apache.jsp.core_jsp cannot override getLastModified(javax.servlet.http.HttpServletRequest) in javax.servlet.http.HttpServlet; attempting to use incompatible return type
found : int
required: long
public int getLastModified(HttpServletRequest req)
^
1 error

Similar Messages

  • Javascript is not working in JSP

    Hi everybody,
    My javascript is not working in JSP.I m not able to fix this problem.Please tell where the problem in code.
    thx in advance.
    <%@page import="javax.servlet.http.*" %>
    <%@page import="java.sql.*" %>
    <html>
    <head>
    <script type="text/javascript" >
    funtion checkentries()
    if(document.LForm.uname.value==null || document.LForm.upassword.value==null)
    alert("Please fill all entries")
    else
    document.LForm.submit()
    </script>
    </head>
    <body>
    <table width=100% height=100% valign="center" align="center" border=0>
    <tr height=10% ><td>
    <%@ include file="Header.jsp" %>
    <hr>
    </td></tr>
    <tr height=1% width=100%>
    <td align=right>Register
    <hr>
    </td>
    </tr>
    <tr height=77% width=100% ><td>
    <table>
    <tr><td width=65%>
    </td>
    <td bgcolor="black" width="1" ></td>
    <td align="right" valign="top" >
    <form method="POST" action="/EIS/Home.do" name="LForm">
    User Name: <input type="text" align=right name="uname"><br>
    Password: &nbsp&nbsp&nbsp<input type="password" name="upassword"><br>
    <input type="submit" name="submit" value="Submit" onclick="checkentries()">
    </td>
    </tr>
    </table>
    </td></tr>
    <tr height=10% ><td>
    <hr>
    <%@ include file="Footer.jsp" %>
    </td></tr>
    </table>
    </body>
    </html>

    in this part:
    if(document.LForm.uname.value==null || document.LForm.upassword.value==null)should be:
    if(document.LForm.uname.value=="" || document.LForm.upassword.value=="")or
    if(document.LForm.uname.value.length==0 || document.LForm.upassword.value.length==0)

  • Filter does not work with *.jsp URL pattern???

    Hi All,
    I am, by no means, very good at JSF or Java. I have looked at various forum posts on here for ways to implement a security filter to intercept requests to pages that first require one to be logged in, and if not, redirect them to the login page. Yes, I know a lot of you have heard this many times before, and I'm sorry to bring it up again.
    BUT, from the guidance of other posts, I have got a filter that works fine when the url pattern is set to "/faces/*" or "/<anything>/*", however it won't work for "*.jsp" or "*.<anything>"
    My filter is as follows:
    package test.security;
    import javax.faces.context.FacesContext;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.http.HttpSession;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class SecurityFilter implements Filter{
        /** Creates a new instance of SecurityFilter */
        private final static String FILTER_APPLIED = "_security_filter_applied";
        public SecurityFilter() {
        public void init(FilterConfig filterConfig) {
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws java.io.IOException, ServletException{
            HttpServletRequest req = (HttpServletRequest)request;
            HttpServletResponse res = (HttpServletResponse)response;
            HttpSession session = req.getSession();
            String requestedPage = req.getPathTranslated();
            String user=null;
            if(request.getAttribute(FILTER_APPLIED) == null) {
                //check if the page requested is the login page or register page
                if((!requestedPage.endsWith("Page1.jsp")) /* This is the login page */
                    //set the FILTER_APPLIED attribute to true
                    request.setAttribute(FILTER_APPLIED, Boolean.TRUE);
                    //Check that the session bean is not null and get the session bean property username.
                    if(((test.SessionBean1)session.getAttribute("SessionBean1"))!=null) {
                        user = ((test.SessionBean1)session.getAttribute("SessionBean1")).getUsername();
                    if((user==null)||(user.equals(""))) {
                       // try {
                     //       FacesContext.getCurrentInstance().getExternalContext().redirect("Page1.jsp");
                      //  } catch (ServletException ex) {
                      //      log("Error Description", ex);
                        res.sendRedirect("../Page1.jsp");
                        return;
            //deliver request to next filter
            chain.doFilter(request, response);
        public void destroy(){
    }My web.xml declaration for the filter is:
    <filter>
      <description>Filter to check whether user is logged in.</description>
      <filter-name>SecurityFilter</filter-name>
      <filter-class>test.security</filter-class>
    </filter>
    <filter-mapping>
      <filter-name>SecurityFilter</filter-name>
      <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    Note: I have also tried this with <url-pattern>*.jsp</url-pattern> for the filter mapping in place of the Faces Servlet
    My web.xml declaration for the url pattern is:
    <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.jsp</url-pattern>
    </servlet-mapping>Which JSC/NetbeansVWP automatically creates a "JSCreator_index.jsp" which has:
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root  version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page">
      <jsp:forward page="Page1.jsp"/>
    </jsp:root>When run, this causes an Error 500 in the browser and a NullPointerException in SecurityFilter.java on the line:
    if((!requestedPage.endsWith("Page1.jsp")) /* This is the login page */I think I'm missing something that would be obvious to anyone who knows better than me. Any ideas?

    Dear Ginger and Boris,
    thanks for the information - the problem seems to ocur in EP7 as well, Boris told me it is fixed in SP15. We are on SP14 now, so there is hope !
    actually the information in the oss note stated above is also true, as we have an Oracle DB. On a similar demo system (only difference is SQL DB) the hyphen search works !
    best regards, thank you !
    Johannes

  • Urgent: SAX parser bean is not working in JSP page

    Hi All,
    I have created a bean "ReadAtts" and included into a jsp file using
    "useBean", It is not working. I tried all possibilities. But Failed Plz Help me.
    Below are the details:
    Java Bean: ReadAtts.java
    package sax;
    import java.io.*;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import java.util.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    import javax.xml.parsers.ParserConfigurationException;
    public class ReadAtts extends DefaultHandler implements java.io.Serializable
         private Vector attNames = new Vector(); //Stores all the att names from the XML
         private Vector attValues = new Vector();
         private Vector att = new Vector();
         private Locator locator;
         private static String start="",end="",QueryString="",QString1="",QString2="";
    private static boolean start_collecting=false;
         public ReadAtts()
         public Vector parse(String filename,String xpath) throws Exception
    QueryString=xpath;
         StringTokenizer QueryString_ST = new StringTokenizer(QueryString,"/");
         int stLen = QueryString_ST.countTokens();
         while(QueryString_ST.hasMoreTokens())
              if((QueryString_ST.countTokens())>1)
              QString1 = QueryString_ST.nextToken();
    else if((QueryString_ST.countTokens())>0)
                   QString2 = QueryString_ST.nextToken();
         SAXParserFactory spf =
    SAXParserFactory.newInstance();
    spf.setValidating(false);
    SAXParser saxParser = spf.newSAXParser();
    // create an XML reader
    XMLReader reader = saxParser.getXMLReader();
    FileReader file = new FileReader(filename);
    // set handler
    reader.setContentHandler(this);
    // call parse on an input source
    reader.parse(new InputSource(file));
         att.add("This is now added");
         //return attNames;
    return att;
    public void setDocumentLocator(Locator locator)
    this.locator = locator;
    public void startDocument() {   }
    public void endDocument() {  }
    public void startPrefixMapping(String prefix, String uri) { }
    public void endPrefixMapping(String prefix) {  }
    /** The opening tag of an element. */
    public void startElement(String namespaceURI, String localName,String qName, Attributes atts)
    start=localName;
    if(start.equals(QString2))
    start_collecting=true; //start collecting nodes
    if(start_collecting)
    if((atts.getLength())>0)
    for(int i=0;i<=(atts.getLength()-1);i++)
    attNames.add((String)atts.getLocalName(i));
    attValues.add((String)atts.getValue(i));
    /** The closing tag of an element. */
    public void endElement(String namespaceURI, String localName, String qName)
    end = localName;
    if(end.equals(QString2))
         start_collecting=false; //stop colelcting nodes
    /** Character data. */
    public void characters(char[] ch, int start, int length) { }
    /** Ignorable whitespace character data. */
    public void ignorableWhitespace(char[] ch, int start, int length){ }
    /** Processing Instruction */
    public void processingInstruction(String target, String data) { }
    /** A skipped entity. */
    public void skippedEntity(String name) { }
    public static void main(String[] args)
    String fname=args[0];
    String Xpath=args[1];
    System.out.println("\n from main() "+(new ReadAtts().parse(fname,Xpath)));
    //System.out.println("\n from main() "+new ReadAtts().attNames());
    //System.out.println("\n from main() "+new ReadAtts().attValues());
    JSP File:
    <%@ page import="sax.*,java.io.*,java.util.*,java.lang.*,java.text.*;" %>
    <jsp:useBean id="p" class="sax.ReadAtts"/>
    Data after Parsing is.....
    <%=p.parse"E:/Log.xml","/acq/service/metrics/system/stackUsage")%>
    Expected Output:
    The jsp file should print all the vector objects from the "ReadAtts" bean
    Actual Output:
    Data after Parsing.......[]
    Thanks for your time.....
    Newton
    Bangalore. INDIA

    the problem is not because of java code insdie jsp page
    I have removed all things but the form and it is still not working
    here is the modified code:
    <!-- add news-->
    <%
    if(request.getParameter("addBTN") != null){
            out.print("addBTN");
    %>
    <!-- end of add news-->
    <form action="" method="post" enctype="multipart/form-data" name="upform" >
      <table width="99%" border="0" align="center" cellpadding="1" cellspacing="1">
        <tr>
          <td colspan="2" align="right" bgcolor="#EAEAEA" class="borderdTable"><p>'6'A) .(1 ,/J/</p></td>
        </tr>
        <tr>
          <td width="87%" align="right"><label>
            <input name="title" type="text" class="rightText" id="title">
          </label></td>
          <td width="13%" align="right">9FH'F 'D.(1</td>
        </tr>
        <tr>
          <td align="right"><textarea name="elm1" cols="50" rows="10" id="elm1" style="direction:rtl" >
              </textarea></td>
          <td align="right">*A'5JD 'D.(1</td>
        </tr>
        <tr>
          <td align="right"><label>
            <input type="file" name="filename" id="filename">
          </label></td>
          <td align="right">5H1)</td>
        </tr>
        <tr>
          <td align="right"><label>
            <input name="addBTN" type="submit" class="btn" id="addBTN" value="  '6'A) .(1 ">
          </label></td>
          <td align="right"> </td>
        </tr>
      </table>
    </form>
    <!-- TinyMCE -->
    <script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript">
            tinyMCE.init({
                    mode : "textareas",
                    theme : "simple",
                    directionality : "rtl"
    </script>
    <!--end of TinyMCE -->

  • HTML multipart form is not working in jsp page

    Hi
    i have jsp page, has a HTML from with file upload field , when i click the send button , nothing happened as if the button did not submit the form. ie the message at line 12 is not printed out.
    can any one help please.
    <%@ page errorPage="..\error\error.jsp" %>
    <%@ page pageEncoding="windows-1256" %>
    <%@ page language="java" import="javazoom.upload.*,java.util.*,java.sql.ResultSet" %>
    <jsp:useBean id="upBean" scope="page" class="javazoom.upload.UploadBean" >
      <jsp:setProperty name="upBean" property="folderstore" value="<%=request.getRealPath("thuraya//uploads")%>"  />
    </jsp:useBean>
    <jsp:useBean id="dbc" class="mypackage.DBConnection" scope="session" />
    <!-- add news-->
    <%
    if(request.getParameter("addBTN") != null){
            out.println("addbtn");
            //do upload file + insert in database
             if (MultipartFormDataRequest.isMultipartFormData(request))
             // Uses MultipartFormDataRequest to parse the HTTP request.
             MultipartFormDataRequest mrequest = new MultipartFormDataRequest(request);
             String todo = null;
             if (mrequest != null) todo = mrequest.getParameter("todo");
                 if ( (todo != null) && (todo.equalsIgnoreCase("upload")) )
                    Hashtable files = mrequest.getFiles();
                    if ( (files != null) && (!files.isEmpty()) )
                        UploadFile file = (UploadFile) files.get("filename");
                        if (file != null)
                                            out.println("<li>Form field : uploadfile"+"<BR> Uploaded file : "+file.getFileName()+" ("+file.getFileSize()+" bytes)"+"<BR> Content Type : "+file.getContentType());
                                            String fileName=file.getFileName();
                                            String ran=System.currentTimeMillis()+"";
                                            String ext=fileName.substring(   ( fileName.length()-4),fileName.length() );
                                            file.setFileName(ran+ext);
                        // Uses the bean now to store specified by jsp:setProperty at the top.
                        upBean.store(mrequest, "filename");
                                            String title=request.getParameter("title");
                                            String content=request.getParameter("elm1");
                                            int x=dbc.addNews(title,content,file.getFileName(),2,1);
                                            if(x==1)
                                                     out.print("New Vedio has been addedd Successfully");
                                                      response.setHeader("Refresh","1;URL=uploadVedio.jsp");
                                                     else{
                                                      out.print("An Error Occured while adding new Vedio");
                                                      response.setHeader("Refresh","1;URL=uploadVedio.jsp");
                    else
                      out.println("<li>No uploaded files");
             else out.println("<BR> todo="+todo);
    %>
    <!-- end of add news-->
    <form action="" method="post" enctype="multipart/form-data" name="upform" >
      <table width="99%" border="0" align="center" cellpadding="1" cellspacing="1">
        <tr>
          <td colspan="2" align="right" bgcolor="#EAEAEA" class="borderdTable"><p>'6'A) .(1 ,/J/</p></td>
        </tr>
        <tr>
          <td width="87%" align="right"><label>
            <input name="title" type="text" class="rightText" id="title">
          </label></td>
          <td width="13%" align="right">9FH'F 'D.(1</td>
        </tr>
        <tr>
          <td align="right"><textarea name="elm1" cols="50" rows="10" id="elm1" style="direction:rtl" >
              </textarea></td>
          <td align="right">*A'5JD 'D.(1</td>
        </tr>
        <tr>
          <td align="right"><label>
            <input type="file" name="filename" id="filename">
          </label></td>
          <td align="right">5H1)</td>
        </tr>
        <tr>
          <td align="right"><label>
            <input onClick="submit()" name="addBTN" type="button" class="btn" id="addBTN" value="  '6'A) .(1 ">
          </label></td>
          <td align="right"> </td>
        </tr>
      </table>
    </form>
    <!-- TinyMCE -->
    <script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript">
            tinyMCE.init({
                    mode : "textareas",
                    theme : "simple",
                    directionality : "rtl"
    </script>
    <!--end of TinyMCE -->

    the problem is not because of java code insdie jsp page
    I have removed all things but the form and it is still not working
    here is the modified code:
    <!-- add news-->
    <%
    if(request.getParameter("addBTN") != null){
            out.print("addBTN");
    %>
    <!-- end of add news-->
    <form action="" method="post" enctype="multipart/form-data" name="upform" >
      <table width="99%" border="0" align="center" cellpadding="1" cellspacing="1">
        <tr>
          <td colspan="2" align="right" bgcolor="#EAEAEA" class="borderdTable"><p>'6'A) .(1 ,/J/</p></td>
        </tr>
        <tr>
          <td width="87%" align="right"><label>
            <input name="title" type="text" class="rightText" id="title">
          </label></td>
          <td width="13%" align="right">9FH'F 'D.(1</td>
        </tr>
        <tr>
          <td align="right"><textarea name="elm1" cols="50" rows="10" id="elm1" style="direction:rtl" >
              </textarea></td>
          <td align="right">*A'5JD 'D.(1</td>
        </tr>
        <tr>
          <td align="right"><label>
            <input type="file" name="filename" id="filename">
          </label></td>
          <td align="right">5H1)</td>
        </tr>
        <tr>
          <td align="right"><label>
            <input name="addBTN" type="submit" class="btn" id="addBTN" value="  '6'A) .(1 ">
          </label></td>
          <td align="right"> </td>
        </tr>
      </table>
    </form>
    <!-- TinyMCE -->
    <script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
    <script type="text/javascript">
            tinyMCE.init({
                    mode : "textareas",
                    theme : "simple",
                    directionality : "rtl"
    </script>
    <!--end of TinyMCE -->

  • Navigation button not working in JSP

    JDeveloper10g JSP:
    "NestSet", "PreviousSet" button not working after a search is done on a read-only table. Is this a know bug?
    Please help!!!

    Vishal,
    I dont think the Notification Create Button from line item is pretty much dependent on the Customization Settings or any sap note concerning this has not been as yet brought into my notice. In my system, this is working appropriately. The problem with this which i can think of is either an authorization issue or you should raise an oss for this.
    Regards,
    Usman

  • Weblogic 9.1/10 not working on jsp:directive.include file="file.jspf"/

    Does anyone know how to get rid of this problem? I have a jsp page including a sun java studio creator created page fragment using the tag:
    <jsp:directive.include file="myHeader.jspf"/>
    here myHeader.jspf is a page fragment.
    after deployment, weblogic server report error as:
    weblogic.servlet.jsp.CompilationException: Failed to compile JSP /Page1.jsp
    Page1.jsp:15:57: Error in "C:\bea\user_projects\domains\base_domain\servers\AdminServer\tmp\_WL_user\proj\grb4mk\war\myHeader.jspf" at line 1: The encoding "null" specified in the XML prolog is unsupported.
    <jsp:directive.include file="myHeader.jspf"/>
    ^----------------^
    Any idea? I tried both weblogic 9 and 10, same error, change to
    <jsp:include page="myHeader.jspf"/>
    works. the question is: why not read jsp 1.2 tag? Any way to make it work with jsp:directive.include tag?
    thanks in advance.
    Edited by: user10243594 on Sep 10, 2008 10:22 AM

    The "jsp:directive.include" tag is only valid in an well-formed XML file that specifies all the relevant namespaces. The "jsp:include" tag is used in a JSP file. I'll bet the beginning of your file shows that you don't have a valid and well-formed XML file.
    If you found that "jsp:include" worked, then that confirms you have an ordinary JSP file here. Why are you trying to use the XML form? The result of "jsp:include" in a JSP file will be exactly the same as the analogous tag in an XML file.

  • Servlet filters on Tomcat 6. Not working on JSPs?

    Hi there:
    First of all I want to apologize because I'm not sure if this is the best place to ask a question like this, as it may have more to do with the treatment which Tomcat gives to JSPs more than the servlet filter standard. Anyway, here I go...
    I'm new into the servlet filter's world (well, nor an expert in Java). To start from a point, I decided to try an example from Sing Li, on the IBM website. The code can be watched and downloaded here (the second one): [http://www.ibm.com/developerworks/java/library/j-tomcat/] .
    This filter basically replaces a certain string in the response output (if found) by the dessired one. I've tested this code "as is" (well, changing the package only) and works great for pure servlets. However, testing this with JSPs outputs a simple and plain blank. Doing some research, I've realized that the problem could be in the class which inherits from HttpServletResponseWrapper. Instead of building a new ServletOutputStream I decided to re-utilize exactly the same which comes from the original "request" object but the problem persisted.
    Another user, Giampaolo Tomassoni, faced a similar a problem. A message from him can be found here . He solved this overriding the "flushBuffer ()" method on the class which inherits from HttpServletResponseWrapper. I've tryed to the same, forcing the flush of the ServletOutputStream and the PrintWritter without any luck.
    By the way, I've made sure that filters work on JSPs. Indeed, I've tested others and have done ok. This seems to be related to HttpServletResponseWrapper.
    Do you have any idea about what could be the reason? Many thanks in advance :) .

    I have the same issue.  My 3-month-old Iphone 6 128 GB model (60 GB free) was working fine yesterday.  I did not install any new apps, although typically 5-10 apps update automatically every night.  Today, out of the blue, about 80% of my apps will not load -- the app window opens then immediately crashes to home page (a double press shows the app is still in memory, but when I select it, it pops up for an instant, then goes back to home icon screen.  Example apps (CNN, CBS News, ABC News, NBC News, Scrabble, many others). I tried turning phone off and back on (three times) - no change. Then tried a hard reset (hold power button and home button down simultaneously for 10 seconds) - on reboot still no change.  Then I tried a Restore from backup on my PC - after restarting and clicking through all the welcome to ios 8 screeens - no change; most apps still crash immediately after starting.
    I took my phone to the Verizon store where I bought it.  The agent tried the power off - power on routine again with no success. I informed him that I also tried the restore from backup at home with no success.  He authorized a warranty replacement and my new replacement iPhone will be FEDEXed to my home Tuesday.  Hope this one works after a restore from backup and this isn't some colossal bug with the latest software update (IOS 8.1.3), which I installed about a week ago.  Internet searches reveal that a number of folks are having problems with their 128gb iphone6 devices - something about bad NAND memory.
    Stats on my iPhone 6, in case others have similar problems, so we can possibly identify a trend:  4,831 songs; 1 video, 3,912 photos, 392 applications, 114 gb capacity, 59.8 gb free, version 8.1.3, carrier Verizon 18.1, Model MG602LL/A.
    Has anyone else started having problems with apps suddenly refusing to work on their 128 gb iPhone6?

  • If condition statement not working in jsp scriptlet

    <%
    String hostName = java.net.InetAddress.getLocalHost().getCanonicalHostName();
    if(hostName.endsWith("dinesh.com"))
    System.out.println("it works");
    else {
    System.out.println("it doesn't work");
    %>
    I am getting output as it works & it doesn't work. It seems the If condition is not working. Pls help with this issue.
    Thanks

    Dinesh_Nala wrote:
    Even the condition in if is returning true, the x value i am get as "/user2/"How did you knew that it returns true? Or did you just expect that? Do you trust yourself more than Java? Too bad.
    Just debug it:
    System.out.println("Actual hostname value: [" + hostName + "]");
    System.out.println("Does it end with dinesh.com? " + hostName.endsWith("dinesh.com"));

  • Creating a link to text file in a tomcat server not working in JSP webapp

    I am using netbeans to create an web application within my desktop, and then I load the build/web folder to a tomcat server to test the application. Everything works fine. However, when I try to link up my JSP pages to text files (.txt) create by the application on the server, I seem to be getting files that might be kept in a terminal.
    When I get the Real path of the servlet context, I find that it is to a C:\ type file rather than a //hostname type of directory. So obviously those files are not being reached.
    Does anybody know how to deal this problem?

    There are a number of ways to get to the Flash Global Security settings dialog.
    My favourite way is just to double click on a Captivate SWF (not the HTM file) to open it in a web browser, then right click on the playing screen to get the Flash context menu.  On the context menu, click the Global Settings option.
    In the web page that opens, click the link on the left to Global Security Settings.
    Add the folder or drive location of your published Captivate content to the Trusted Locations.

  • Java code not working in Jsp page....

    I like to say to myself "there is no magic" when I come to a perplexing situation, today is one of those times.
    The following code when executed from the java class retrieves all the specified objects from the database and displays the requested attributes without issue:
    try {
    DBBody dbb = new DBBody();
    Entity[] allbods = dbb.retrieveAll(true);
    for(int k=0;k < allbods.length;k++) {
    Body body = (Body)allbods[k];
    System.out.println("From the dbase index position: " + k +" : " + "\n" + "Id: " + body.getId() + "\n" + "Type: " + body.getType() + "\n" + "Load: " + body.getLoad() + "\n XML:" + body.toXml() + "\n");
    dbb.close();
    } catch (Exception adb) {
    adb.printStackTrace();
    : the **exact same** code as displayed above when run in a Jsp only lists the values for the "body.getId()" and "body.getType()" methods...for a reason I can't discern, "body.getLoad()" and "body.toXml()" return empty strings in the Jsp. Everything else returns as when the code is run from the class. Both "getLoad()" and "toXml()" return strings but behind the scenes use StringBuffer objects that are converted to Strings...getId() returns an int and "getType()" returns a String also, but for whatever reason (to repeat) only those two attributes come through IN THE JSP, in the class ALL attributes are retrieved without a problem...so, what is wrong with Jsp? Java? I get no error message what so ever, just empty strings for the two specified method returns...what am I overlooking. I am running the embedded Jsp engine of the Jetty Http Server that I've incorporated into my application, which uses the latest Jsp version.
    Any help on this issue would be greatly appreciated.

    If you dont want to paste your code, then you will
    certainly not get any responses from the so called
    Java Engineers rest is left to you. We can get dukes
    elsewhere instead.
    SwarajSwaraj, I apologize if I was taken to be abrassive with my last comment, I myself am a java engineer so I have no animosity, as for your request to copy the entire code it is no longer needed I have solved the problem and the solution follows just incase anyone else runs into similar issues. It indeed had nothing to do with StringBuffer working improperly but rather it was how I was getting my dbase connection.
    As many of you who have developed applications with jdbc support to popular dbase vendors may already know, a connection must be established to the database by specifying various parameters, namely the name of the jdbc connection driver classes for the desired vendor (eg. "com.microsoft.jdbc.sqlserver.SQLServerDriver" for MS Sql Server instances) and the driver specific db connection url. Of course the driver classes must be available on the class path so that they can be accessed. Without these parameters the connection will not be initialized..well it turns out my "bug" was caused by my inadvertently ommitting the connection parameters in my Jsp, you might wonder "but you said it executed fine in the jsp except for the missing "getBody()" and "toXml()" results..how could it even execute at all if you didn't establish a connection?"
    The answer is I designed the application to use a default connection driver class (the jdbc odbc bridge driver) and a default connection url (one that is tied to my testing instance of MsSqlServer2000) it turns out that the jdbc odbc bridge is very light weight...it lacks support for certain very useful MsSql datatypes namely "ntext", I use the "ntext" type for fields that can grow to any size (stylesheet code,xml code...etc.) but the bridge driver doesn't support "ntext" BUT rather than throw an exception error like proper error handling would require it silently eats the request (very very bad) ...this exacerbated the problem I had significantly (had it thrown an error I would have known immediately that the connection was using the wrong driver and url and fixed it sooner) as it is ...I was led down blind allies thinking my code was faulty, (which it wasn't strictly speaking ..I was just missing some extra code to account for the possibility that the bridge driver is instantiated by accident) so after adding the following code above the Jsp code shown previously:
    //Configure a connection to a Microsoft Sql Database.
    DBConfig.setVendorId(DBConfig.MSSQL_VID);
    DBConfig.setDBHostId("xiassql");
    DBConfig.setDBHostPort("1433");
    DBConfig.setDBUrl(DBConfig.buildDBUrl());
    :The code worked perfectly. The "DBConfig" class does exactly that..allowing me to pass in connection attributes including the type of vendor "DBConfig.MSSQL_VID", (I have built in support for 5 popular vendors so far), the dbase host name "xiassql" and the port "1433" , then we build the url using the specified attributes and the connection is complete. After adding the code above the Jsp returned all the retrieved values perfectly. So, when testing applications that enable backend dbase connections if you get seemingly identical code behaving differently from class to Jsp, suspect an issue relating to your connection url and classes (assuming you have multiple support and a default value as I do in my app.) also any changes in the execution context from class to Jsp can cause similar errors (like not declaring the same classes at the top of the Jsp file , or less likely using an outdated Jsp engine!)
    Regards,
    PS I will take off the Duke Dollars on this question since I answered it myself!

  • Bean not working in jsp

    OK, maybe I'm oversharing, but I want to be thorough. Note I asked this question a different way using very different code.
    Here's my jsp file - myq.jsp
    <%@ page language="java" import="java.util.*,com.serco.inquire.*" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="inq" tagdir="/WEB-INF/tags" %>
    <inq:displayCollection>
    <jsp:attribute name="mgr">Chris Novish</jsp:attribute>
    </inq:displayCollection>Here's displayCollection.tag used by that jsp:
    <%@ tag body-content="scriptless" import="com.serco.inquire.*" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ attribute name="mgr" required="true" %>
    <jsp:useBean id="irc" scope="session" class="com.serco.inquire.IrCollection">
      <jsp:setProperty name="irc" property="mgrid" value="${mgr}" />
    </jsp:useBean>
    ${irc.size} | ${irc.mgrid}Here's the java class IrCollection (used as a bean in the tag):
    package com.serco.inquire;
    import java.sql.*;
    import java.util.*;
    public class IrCollection {
         public ArrayList iRecords = new ArrayList<InquireRecord>();
         public int size;
         public String mgrid;
         public irCollection() {
              super();
         public void populateCollection() {
              try {
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   String filename = "inquire.mdb";
                   String database = "jdbc:odbc:Driver={Microsof Access Driver (*.mdb)};DBQ=";
                   database+= filename.trim() + ";DriverID=22;READONLY=true}";
                   Connection con = DriverManager.getConnection( database ,"","");
                   Statement s = con.createStatement();
                   s.execute ("SELECT * FROM inquiries WHERE manager = '" + this.mgrid + "'");
                   ResultSet rs = s.getResultSet();
                   int cur;
                   while (rs.next()) {
                        cur = rs.getRow()-1;
                        InquireRecord localIR = new InquireRecord();
                        int curID = rs.getInt("ID");
                        localIR.setID(curID);
                        String cursub = rs.getString("submitter");
                        localIR.setSubmitter(cursub);
                        this.iRecords.add(cur, localIR);
                   con.close();
                   this.size = iRecords.size();
              catch (Throwable e) {
                   System.out.println(e);
         public int getSize () {
              return this.size;
         public void setMgrid(String datum) {
              this.mgrid = datum;
              this.populateCollection();
         public String getMgrid() {
              return this.mgrid;
    }and here's the InquireRecord java class used by IrCollection:
    package com.serco.inquire;
    public class InquireRecord {
         private int ID;
         private String submitter;
         public InquireRecord() {
              super();
         public InquireRecord(String asubmitter) {
              this.submitter = asubmitter;
         public int getID(){
              return this.ID;
         public void setID(int datum) {
              this.ID = datum;
         public String getSubmitter() {
              return this.submitter;
         public void setSubmitter(String datum) {
              this.submitter = datum;
    }The JSP does this: set the mgr variable, which is passes to the tag, the tag then creates an instance of IrCollection using that mgr variable. (Yes, putting that populateCollection() method call in the setMgrid() method is probably Bad Practice, but it works, usually). The IrCollection objects builds an ArrayList of InquireCollection objects from an Access database. It then sets it's size property based on how many InquireCollection instances it put into the ArrayList. Once that's all done, the tag spits out 2 things: The size property and the mgrid property.
    When I view the JSP, it gives me 0 for the size and Chris Novish for the mgrid.
    I think this could be one of the following:
    *Not finding any matching records of the database
    *Not actually executing the populateCollection() method
    *some how forgetting the information it put into that ArrayList?
    I"m sure there's another possibility, but I don't know.
    Here's what gets me. Here's a test class I made called TestCollection:
    {code}package com.serco.inquire;
    import java.util.*;
    import java.text.*;
    public class TestCollection {
         public static void main(String[] args) {
              IrCollection myCollection = new IrCollection();
              myCollection.setMgrid("Chris Novish");
              System.out.println(myCollection.getSize());
              System.out.println(myCollection.getMgrid());
    }{code}
    if I run that I get a size of 4 and a mgrid of Chris Novish.
    Same data in, and it works as expected.
    So... why won't JSP do it?

    You have defined a session scope for that bean. You have to make sure that the bean is instantiated by this jsp and not earlier. If the bean is located in the session because it was set earlier, then the body tags within useBean are not evaluated.
    Look here - http://java.sun.com/products/jsp/tags/syntaxref.fm14.html#8865
    An easy way to test it would be to change the scope of the bean to request.
    ram.

  • ListIterator not working in JSP page

    Hello,
    I am using an ArrayList in a JSP as follows:
    <%
    ArrayList missingFieldsArr = (ArrayList) HeaderBean.getMissingFieldsArr();
    ListIterator i = (ListIterator)missingFieldsArr.listIterator();
    %>
    <hbj:scrollContainer
      id="scrContError"
      width="320"
      height="50"
    >
      <table width="60%">
      <% while(i.hasNext()) {
        String str = (String) i.next();
      %>
        <tr>
          <td width="100%"> 
            <hbj:textView
           id="txtErrorLst"
           wrapping="true"
           text="<%=str%>"
         />     
         </td>
       </tr>     
      <% } %>
      </table>
    </hbj:scrollContainer>
    Iterating through the ArrayList works when I test via portalapp.xml in NDS, but it does not when I test via the iview in the Portal.  The error I'm receiving is:
    Portal Runtime Error
    An exception occurred while processing a request for :
    iView : pcd:portal_content/com.nbcuni.sc_portal_Content/com.nbcuni.Roles/com.nbcuni.SAP_SC_Testing_Pre-Bom/com.nbcuni.product_information_prebom_ws/com.nbcuni.pre_bom_pg/com.nbcuni.pre_bom
    Component Name : PBS.Inbox
    The exception was logged. Inform your system administrator..
    Exception id: 06:37_30/12/05_0106_4554750
    See the details for the exception ID in the log file
    Any thoughts? 
    Thanks for your help,
    -Jamie

    Hi Jamie,
    for what reason do you think it's the list iterator? All you know from the info you have passed through to us, that it is your component...
    > Exception id: 06:37_30/12/05_0106_4554750
    > See the details for the exception ID in the log file
    ==> Please submit the detailed exception / message / stacktrace from the default.X.trc file.
    Best regards
    Detlev

  • Java script not working in JSP.

    Hi everyone
    I've got a problem with a java scipt that's not doing what I want it to do.
    I have a jsp which gets data from a database to display.
    On the jsp there is a "add" button which on click will open another jsp to add a contact, when I add the contact the jsp calls a web servlet which adds the contact to the database.
    After the contact is added the servlet directs the page back to the contacts page, and it must display the newly added contact in the jsp.
    I've configured a script that checks if there is a attribute called "addContact", if it has a value of "added" it must reload the page on load, which in turn will display the newly added contact, it refreshes but it doesn't display the newly added contact, it worked but after awhile it stopped working.
    Beneath is my code for the contact list jsp and the servlet.
    ContactList.jsp
    <?xml version="1.0"?>
    <%@ page import="contacts.Contacts"%>
    <%@ page import="java.util.*"%>
    <jsp:useBean id = "contactsData" scope = "page" class ="contacts.ContactsData"/>
    <html>
         <head>
              <title>Contact List</title>
              <script language=JavaScript>
              <!--
                   function clicked(clickedValue)
                        if(clickedValue == "add")
                             window.location = "AddContact.jsp";
              -->
              </script>
         </head>
              <%
              String refreshSession = (String)session.getAttribute("addContact");
              if(refreshSession != null && refreshSession.equals("added"))
              %>
              <body onload="window.location.reload(true);">
              <%
              session.removeAttribute("addContact");
              else
              %>
              <body>
              <%
              %>
              <h1>Contacts</h1>
              <form>
                   <table cellpadding="5">
                        <%
                             ArrayList contactList = contactsData.getContacts();
                             Iterator contactsIterator = contactList.iterator();
                             Contacts contacts;
                             while(contactsIterator.hasNext())
                                  contacts = (Contacts) contactsIterator.next();
                                  String contactName = contacts.getContactName();
                        %>
                                  <tr>
                                       <td><input type="radio" name="deleteContact" value=<%=contactName%>></td>
                                       <td><a href = "UpdateContact.jsp?paramName=<%=contactName%>"><%=contactName%></a></td>
                                       <td><%=contacts.getCompany()%></td>
                                       <td><%=contacts.getWorkNumber()%></td>
                                       <td><a href = "mailto:<%=contacts.getEmail() %>"><%=contacts.getEmail() %></a>
                                  </tr>
                        <%
                        %>
                   </table>
                        <br>
                        <input type="button" value="Add" onClick="clicked('add')"/>
              </form>
         </body>
    </html>NewContactServlet.java
    package contacts;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import contacts.*;
    public class NewContactServlet extends HttpServlet
         public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
              res.setHeader("Expires", "Tues, 01 Jan 1980 00:00:00 GMT"); //no cache allowed
              HttpSession session = req.getSession(true); //get current session
              String contactssession = (String)session.getAttribute("contactsSession");
              if(contactssession.equals("add"))
                   Contacts contacts = new Contacts();
                   ContactsData contactsData = new ContactsData();
                   contacts.setContactName(req.getParameter("contactName"));
                   contacts.setCompany(req.getParameter("companyName"));
                   contacts.setWorkNumber(req.getParameter("workNum"));
                   contacts.setCellNumber(req.getParameter("cellNum"));
                   contacts.setFaxNumber(req.getParameter("faxNum"));
                   contacts.setEmail(req.getParameter("email"));
                   contacts.setCountry(req.getParameter("country"));
                   contactsData.addContact(contacts);
              else if(contactssession.equals("add"))
              session.setAttribute("addContact","added");
              res.sendRedirect("ContactList.jsp");
    }

    Ren2407 wrote:
    Hi stevejluke
    Thanks for the reply.
    ContactsData stores the Contacts into a database, Access to be precise.
    The store of the Contacts works fine and it gets redirected to the ContactsList.jsp page, but I need to click refresh on the browser to see the new
    contact. I've tried to make it load automatically when the browser opens but it wouldn't, it worked before.
    I'm using Apache to host the webpage.I don't see any errors.So lemme get this straight:
    You have the contactsList.jsp which when Add is clicked you go to addContact.jsp in the same window. Then when addContact is submitted it goes to the neContact servlet which adds the contact to the database and then sends a redirect back to the contactsList.jsp.
    When contactsList.jsp is re-shown it doesn't display the new data so you are using javascript to force-refresh the page, which used to work, but doesn't anymore.
    My guess is that your browser or some proxy between your browser and server is caching the page. You have to tell all clients not to cache that page using META tags:
    <?xml version="1.0"?>
    <%@ page import="contacts.Contacts"%>
    <%@ page import="java.util.*"%>
    <jsp:useBean id = "contactsData" scope = "page" class ="contacts.ContactsData"/>
    <html>
         <head>
              <title>Contact List</title>
                    <meta HTTP-EQUIV="expires" CONTENT="0" />
                    <meta HTTP-EQUIV="Pragma" CONTENT="no-cache" />
                    <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache" /> You could then get rid of your javascript refresh code altogether.
    p.s. I am a big fan of using JSTL. Try to get rid of all your scriptlets and replace it with JSTL. It would look something like this:
              <h1>Contacts</h1>
              <form>
                   <table cellpadding="5">
                        <c:forEach var="contact" items="${contactsData.contacts}">
                                  <tr>
                                       <td><input type="radio" name="deleteContact" value="${contact.name}"></td>
                                       <td><a href = "UpdateContact.jsp?paramName=${contact.name}">${contact.name}</a></td>
                                       <td>${contact.company}</td>
                                       <td>${contact.workNumber}</td>
                                       <td><a href = "mailto:${contact.email}">${contact.email}</a>
                                  </tr>
                        </c:forEach>
                   </table>
                        <br>
                        <input type="button" value="Add" onClick="clicked('add')"/>
              </form>

  • It is not working when jsp is outside of the Controller(.jpf) directory

    Hello,
    I am new to Portal. I am using Weblogic 8.1SP2. The problem is when there is a general jsp I want to put it common directory. It is working fine when I run starting from individual Controller but When I put its portlet in Portal, then the action is NOT falling into its caller's Controller but into the root Controller. Is this normal ? Is there a way to have the action call back to its caller Controller ? The director structure is :
    ../portalWeb
    + flowControllers
    + common
    search.jsp
    + portlet1
    Portlet1Controller.jpf
    Portlet1Controller.portlet
    + portlet2
    Portlet2Controller.jpf
    Portlet2Controller.portlet
    Controller.jpf
    And in the search.jsp file I have javascript snippet code like :
    if ( <%= type%> == 1 ){
    document.forms0].action="startPersonSearch.do"; //Portlet1Controller action
    if ( <%= type %> == 2) {
    document.forms[0].action="startCompanySearch.do"; //Portlet2Controller action
    document.forms[0].submit();
    Please help. Any thought will be greatly appreciated.
    Christina
    Thanks in advance.

    Yes. I did try to put directory path in front of the action to tell which Controller it should go. It didn't throw exception but It acted like called directly from that Controller. It is not under portal.
    Does anyone think the approach to have the common used jsp outside the Controller feasible ?

Maybe you are looking for

  • ITunes crashes when I plug in my iPod

    The problem started with iTunes 9.0.1. My iPod was plugged into my PC and I was playing music from it when it just cut out half way through the song. I tried to bring up iTunes but it was non-responsive. I closed it, restarted my computer and tried a

  • Can LR Web module converting file name hyphens into underscores be disabled

    Hi, I have problems when creating webpages from within LR. First I develop the RAW files and converts them to jpegs. Under Lightroom 3 I use the following settings under "Export location": Export to: Specific Folder Add to This Catalog: ticked Existi

  • Tv out anger

    Okay heres the problem Due to my throwing a fit @ the latest Drivers putting a white screen up on my TV out i formatted my Pc now when i go to play a DVD or anything like that and turn on my TV out it no longer picks up my video clips whats wrong wha

  • Apple TV Activation Failed???

    I recently purchased an Apple TV (2 months ago) and it was working fine but now all of a sudden under General Settings, About, it says activation failed and it will not allow me to view Hulu Tv etc. Also, an error message comes up saying I need to ve

  • Remove applets in Safari iOS7

    I just upgraded my iPad to OS7 and every time I open a new tab in Safari, I get three stupid applets to link me to either Yahoo!, Disney or Apple. I never asked for them, so does anyone know how to get rid of them?