Using getSessionContext() and getIds() in servlets

hello
Problem is getSessionContext() and getIds in servlets are not working at all. I 've a servlet which uses these methods to manupulate sessions what it does'nt work.
getSessionContext() returns session context under which this servlet is running. through this context i want to access all the sessions which are associated with servlet. this context is used with getIds() to get the ids of different sessions. it returns enumeration. but in my case it is always empty even when there are two browsers have valid sessions going on.
so please suggest me some way out
waiting desperately
thanks

As long as you created the session, it should have returned the session id. You may need to post some code.
Bosun

Similar Messages

  • Uploading a file using jsp and com.oreilly.servlet lib package

    Sorry to bother you but I need your help folks
    I am developing an application to pick up files from a database and sent to a specified location on a different system.
    I am presently trying to run this code,I have placed this lib package from oreilly which is supposed to encapsulate the usage of file uploads,which is a jar file called cos.jar into C:\Program Files\Java\jdk1.5.0_03\jre\lib\ext folder .I have a jsp page that calls the bean which does the upload and implement the classes in the oreilly package.I am using tomcat 5
    [b]the jsp page that acts as the user interface
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>Please Choose The File</title>
    </head>
    <body bgcolor="#ffffff">
    <table border="0"><tr>
    <form action="Upload.jsp" method="post"
    enctype="multipart/form-data">
    <td valign="top"><strong>Please choose your document:</strong><br></td>
    <td> <input type="file" name="file1">
    <br><br>
    </td></tr>
    <tr><td><input type="submit" value="Upload File"></td></tr>
    </form>
    </table>
    </body>
    </html>
    this is the jsp page that calls the bean
    <jsp:useBean id="uploader" class="com.UploadBean" />
    <jsp:setProperty name="uploader" property="dir" value="<%=application.getInitParameter(\"save-dir\")%>" />
    <jsp:setProperty name="uploader" property= "req" value="${pageContext.request}" />
    <html>
    <head><title>file uploads</title></head>
    <body>
    <h2>Here is information about the uploaded files</h2>
    <jsp:getProperty name="uploader" property="uploadedFiles" />
    </body>
    </html>
    [b]this is the bean class
    package com;
    import java.util.Enumeration;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.ServletRequest;
    import com.oreilly.servlet.MultipartRequest;
    import com.oreilly.servlet.multipart.DefaultFileRenamePolicy;
    import javax.servlet.*;
    public class UploadBean {
    private String webTempPath;
    private HttpServletRequest req;
    private String dir;
    // private ServletRequest request;
    public UploadBean( ) {}
    public void setDir(String dirName) {
    if (dirName == null || dirName.equals(""))
    throw new IllegalArgumentException("invalid value passed to " + getClass( ).getName( )+".setDir");
    //webTempPath = dirName;
    dir = dirName;
    /* public String getDir()
    return webTempPath;
    public void setReq(ServletRequest request) {
    if (request != null && request instanceof HttpServletRequest)
    req = (HttpServletRequest) request;
    } else {
    throw new IllegalArgumentException("Invalid value passed to " + getClass( ).getName( )+".setReq");
    public String getUploadedFiles( ) throws java.io.IOException{
    //file limit size of 5 MB
    MultipartRequest mpr = new MultipartRequest(req,dir,5 * 1024 * 1024,new DefaultFileRenamePolicy( ));
    Enumeration enume = mpr.getFileNames( );
    StringBuffer buff = new StringBuffer("");
    for (int i = 1; enume.hasMoreElements( );i++){
    buff.append("The name of uploaded file ").append(i).append(" is: ").append(mpr.getFilesystemName((String)enume.nextElement( ))).append("<br><br>");
    }//for
    //return the String
    return buff.toString( );
    } // getUploadedFiles
    On running the code I find this error messages
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: javax/servlet/ServletRequest
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
         org.apache.jsp.jsp.Upload_jsp._jspService(org.apache.jsp.jsp.Upload_jsp:73)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.NoClassDefFoundError: javax/servlet/ServletRequest
         com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:222)
         com.oreilly.servlet.MultipartRequest.<init>(MultipartRequest.java:151)
         com.UploadBean.getUploadedFiles(UploadBean.java:49)
         org.apache.jsp.jsp.Upload_jsp._jspService(org.apache.jsp.jsp.Upload_jsp:63)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
    Apache Tomcat/5.5.9
    tanks

    Hi,
    Looks like you are missing a file from the classpath. Make sure servlet.jar is available in your classpath. Ordinarily files in <tomcat_home>/lib directory should be added automatically. You need to check why it hasn't been added in your case. A good place to start would be the bat files in the bin directory viz startup.bat, catalina.bat etc.
    cheers,
    vidyut

  • Need Help Badly on Shopping Cart Using JSP And Java Servlet

    Hi All,
    This is the 1st time i am trying to create a shopping cart using JSP and Servlet.
    I have read through a few acticles but i still do not get the whole idea of how it works.
    Please guide me as i need help very badly.
    Thanks.
    This is one of the jsp page which displays the category of products user would like to buy : Products.jsp
    <html>
    <head>
    <title>Purchase Order</title>
    </head>
    <body topmargin="30">
    <table border="0" width="100%" id="table1" cellpadding="2">
         <tr>
              <td bgcolor="#990000" width="96">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Code</font></b></td>
              <td bgcolor="#990000" width="260">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Description </font></b></td>
              <td bgcolor="#990000" width="130">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Brand
              </font></b></td>
              <td bgcolor="#990000" width="146">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">UOM
              </font></b></td>
              <td bgcolor="#990000" width="57">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Unit<br>
              Price </font></b></td>
              <td bgcolor="#990000" width="62">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Carton<br>
              Price </font></b></td>
              <td bgcolor="#990000" width="36">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Qty</font></b></td>
              <td bgcolor="#990000" width="65">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Add<br>
              To Cart</font></b></td>
         </tr>
    <tr>
    <td align="center" width="96" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">123</font>
    </td>
    <td align="center" width="260" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Tom Yam</font>
    </td>
    <td align="center" width="130" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Nissin</font>
    </td>
    <td align="center" width="146" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">12 x 10's</font>
    </td>
    <td align="center" width="57" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">$3.85</font>
    </td>
    <td align="center" width="62" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">$46.2</font>
    </td>
    <td align="center" width="36" bgcolor="#CCCCCC">
    <!--webbot bot="Validation" S-Data-Type="Integer" S-Number-Separators="x" -->
    <p align="center"><input type="Integer" name="Q10005" size="1"></p>
    </td>
    <td align="center" width="65" bgcolor="#CCCCCC">
    <p><input type="checkbox" name="checkbox" value="123"></p>
    </tr>
    <tr>
    </table>
    <table border="0" width="100%" id="table2">
         <tr>
              <td>
              <div align="right">          
                   <input type="hidden" name="hAction" value="AddToCart"/> 
              <input type=submit name="submit" value="Add To Cart"/>                     
    </div>
    </td>
         </tr>
    </table>
    </body>
    </html>
    After user has make his selection by entering the qty and ticking on the check box, he would click the "Add To Cart" button ... and this would call my servlet : AddToAddControlSerlvet.java
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    import java.util.*;
    import java.util.ArrayList;
    public class AddToCartControlServlet extends HttpServlet
         public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
              String action = req.getParameter("hAction");
              if (action.equals("AddToCart"))
                   addToCart(req,res);
         public void addToCart(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
              try
                   String url = "";
                   String[] addList = req.getParameterValues("checkbox");
                   HttpSession sess = req.getSession(true);
                   //String sessionID = sess.getId();
                   DBClass dbClass = new DBClass();
                   ArrayList cartList = new ArrayList();
                   for (int i = 0; i < addList.length; i++)
                        String productCode = (String)addList;
                        int qty = Integer.parseInt(req.getParameter("Q"+productCode));
                        Products product = dbClass.getProductDetail(productCode);
                        double totalUnitAmt = qty * product.getUnitPrice();
                        double totalCartonAmt = qty * product.getCartonPrice();
                        Order order = new Order(product.getProductCode(),product.getProductDesc(),product.getBrandName(),product.getUom(),qty,product.getUnitPrice(),product.getCartonPrice(),totalUnitAmt,totalCartonAmt);
                        cartList.add(order);
                   sess.setAttribute("cartList", cartList);
                   url = "/Cart/CartDetails.jsp";
                   ServletContext sc = getServletContext();
                   RequestDispatcher rd = sc.getRequestDispatcher(url);
                   rd.forward(req, res);
              catch (Exception e)
                   System.out.println(e);
    From here, i would get the list of items which user has selected and add to the cartList, then i would direct the user to CartDetails.jsp which displayed the items user has selected.
    From there, user would be able to remove or to continue shopping by selecting other category.
    How i do store all the items user has selected ... everytime he would wan to view his cart ...
    As i would be calling from jsp to servlet .. or jsp to servlet ... and i do not know how i should go about in creating the shopping cart.

    Hi !
    Yon can use a data structure as vector and store the items selected by the user into the vector . Keep the vector in session using session object , so the user can access the entire shopping cart from anywhere in the application .
    Then , you can change the cart accordingly .
    Hope this works.
    Cheers ,
    Pranav

  • Showing various images on browser using JSP and Servlet

    Hello Guys!
    I am starting to develop in Java and already I am facing a big problem.
    If somebody will have some tip or suggestion, will be very well comings!
    The application must present in browser images originnally of format TIF. As it is not a native format of the I.E. , I converted the image for JPG (without saving it on disk) and send it to the browser a encoded image (encode) using JAI library in one servlet had access by a JSP. Then, the structure of my application is thus:
    1) an archive JSP draws the initial screen in browser and presents one input text.
    2) later that the user places the parameter, I make an access to the database and read a quantity of images to be presented.
    3) From there in the proper JSP, I use de tag img src to send image to the browser in agreement archive the amount of images.
    It follows the code of the JSP:
    <% 
                    int intI=0;
                    int intCont=0;
                    if(blnImagem == true){
                        out.println("<br>");
                        out.println("<table border=0 STYLE=border-collapse:collapse>");
                        out.println("<tr>");
                        for(intI=0;intI < Processo.intQtdImagens;intI++){
                           Imagem.strImgTif = Imagem.IndicarImagem(Processo.strNmPath,Processo.strSubPath,Processo.intNuImagem,intI);                                                                    
                           out.println("<th>");
                           out.println("<table border=1 STYLE=border-collapse:collapse rules='cols'>");
                           out.println("<tr>");
                           out.println("<th>");
                           %>
                             <img src="ShowImg" WIDTH=100>
                           <%
                           out.println("</th>");
                           out.println("</tr>");
                           out.println("</table>");
    %>and code on the ShowImg servlet:
            response.setContentType("image/jpeg");       
            ServletOutputStream sos = response.getOutputStream();
            RenderedOp src = JAI.create("fileload", Imagem.strImgTif);           
            ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG",sos,null);       
            encoder.encode(src); 
            sos.close();The problem is if I have 10 images to present, it WILL BE it is executed 10 times and it passes 10 names of different archives, but in the page only the last image is presented 10 times. It is as if it processed the TAG to the end of everything in way that the value of the static variable Imagem.strImgTif was chore only with the last value and the same loaded image 10 times. How I make to solve this? Somebody has some idea?
    THANK YOU !
    Emidio

    If I understand correctly what your problem is:
    Do this in the jsp:
    out.println("<img src=\"ShowImg?image=" + intI + "\" WIDTH=100>");
    In the image servlet, get the "image" parameter and parse it as an int. Move the Imagem.IndicarImagem() call to the image servlet.

  • When to use jsp,and when to use servlet?

    I think that jsp and servlet can realize the same functions, because when run a jsp, it is transferred to a servlet program, so when to use jsp and when to use servlet?
    I am now developing the input interface for a website, I just use jsp and javabean to connect to weblogic and database, and I didn't use servlet, Is there any unseemliness?
    Thank you!

    IMHO I use servlets to control the flow between my jsp's based on a number of factors in a webapp. For instance, user authorization. If a user has the authorization to conduct various administrative functions on an application (like change user rights, reset passwords etc) they will have access to specific buttons or links on some screens that others will not. I use servlets to establish what access rights a user has and direct them to the appropriate pages. I also use servlets to test data validity on form input screens. I know that I can also do this with JavaScript but that can be disabled by the client and in order to prevent that I also double check the form input from a servlet. All my jsp's do is display the results of a business process (which is held in a JavaBean or EJB) and the servlets act as the controllers for the application, connecting to multiple databases, verifying application state, flow control etc. I try to keep the jsp as simple as possible as some of them are maintained by html developers who lack the necessary experience to write java code. I hope this helps.

  • Question regarding use of Log and LogFactory in Servlets

    Hi,
    I saw the following code in an application and I would like to know where the log information would be stored. It appears that the log information is not displayed on the screen and was not able to find out where the log files are. The application was created using NetBeans and was using Tomcat. Thanks in advance.
    import org.apache.common.logging.*;
    public class Test extends HttpServlet
    private static final Log log = LogFactory.getLog(Test.class);
    String theHost;
    String theSource;
    public void init (ServletConfig config) throws ServletException
    super.init(config);
    log.info(�debug Enabled: �+log.isDebugEnabled());
    ServletContext context =config.getServletContext();
    this.thisHost=�/Test/�+config.getServletName();
    etc. etc.
    log.info(�thisHost:�+this.thisHost);
    log.debug(�Source:� +theSource());
    etc, etc.
    }

    It depends on what logging system you have set up.
    Commons.logging is an abstraction layer above logging components. It allows your code to use a variety of logging systems. However those logging systems have to be set up and configured by you. This can be via system properties, properties files, XML config files (depends on the logging system and how you use it).
    So you need to figure out which logging system is being used and then configue that system to write the logs
    matfud

  • How to use an IFrame with my servlet?

    Hello, my question is this (basically, I'm building a "social" application for one of the social networks out there,
    but I'm using a java servlet as my back-end server, though I don't know if it matters to my question) -
    I want to insert an iframe to my application, but I didn't find good material on how to use this, and what to add to my servlet
    for completing the communication with the iframe - can anyone give an example maybe, or a link to a good piece of code.
    Basically, what I want for my application is to simply allow a user to record a voice message, and save it somewhere,
    and for that I need to use a java library, and this is why I thought building it with an iframe that will directly communicate with my java servlet. - IS THIS A GOOD IDEA?
    thanks :)
    Kogan.

    IFrame is just a HTML element. You normally embed HTML elements in a JSP file. How to use an IFrame is covered by every average HTML tutorial.
    What's your actual problem?

  • Uploading a file to server using ajax and struts

    My problem is i wrote a program to upload a file to the server using Ajax.
    Here iam used Struts and Ajax.
    The problem is when iam uploaded a file from my PC the file is uploading to the server in the upload folder located in the server my system.
    Iam using Tomcat server 5.0
    But when iam trying to access it through other system it is not doing so
    Giving an internal server error i,e 500.
    Iam putting the necessary documents for ur reference.
    Plz help me soon .
    My exact requirement is i have to upload a file to the upload folder located in the server.
    And i have to get the path of that file and display the file path exactly below the browse button from where iam uploaded a file.
    That should be done without page refresh and submit thats y iam used Ajax
    Any help would greatly appreciated
    Thanks and Regards
    Meerasaaheb.
    The action class is FilePathAction
    package actions;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.io.*;
    public class FilePathAction extends Action{
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    String contextPath1 = "";
    String uploadDirName="";
    String filepath="";
    System.out.println(contextPath1 );
    String inputfile = request.getParameter("filepath");
    uploadDirName = getServlet().getServletContext().getRealPath("/upload");
    File f=new File(inputfile);
    FileInputStream fis=null;
    FileOutputStream fo=null;
    File f1=new File(uploadDirName+"/"+f.getName());
    fis=new FileInputStream(f);
    fo=new FileOutputStream(f1);
    try
    byte buf[] = new byte[1024*8]; /* declare a 8kB buffer */
    int len = -1;
    while((len = fis.read(buf)) != -1)
    fo.write(buf, 0, len);
    catch(Exception e)
    e.printStackTrace();
    filepath=f1.getAbsolutePath();
    request.setAttribute("filepath", filepath);
    return mapping.findForward("filepath");
    the input jsp is
    filename.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    <script type="text/javascript">
    alertflag = false;
    var xmlHttp;
    function startRequest()
    if(alertflag)
    alert("meera");
    xmlHttp=createXmlHttpRequest();
    var inputfile=document.getElementById("filepath").value;
    xmlHttp.open("POST","FilePathAction.do",true);
    xmlHttp.onreadystatechange=handleStateChange;
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.send("filepath="+inputfile);
    function createXmlHttpRequest()
    //For IE
    if(window.ActiveXObject)
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    //otherthan IE
    else if(window.XMLHttpRequest)
    xmlHttp=new XMLHttpRequest();
    return xmlHttp;
    //Next is the function that sets up the communication with the server.
    //This function also registers the callback handler, which is handleStateChange. Next is the code for the handler.
    function handleStateChange()
    var message=" ";
    if(xmlHttp.readyState==4)
    if(alertflag)
    alert(xmlHttp.status);
    if(xmlHttp.status==200)
    if(alertflag)
    alert("here");
    document.getElementById("div1").style.visibility = "visible";
    var results=xmlHttp.responseText;
    document.getElementById('div1').innerHTML = results;
    else
    alert("Error loading page"+xmlHttp.status+":"+xmlHttp.statusText);
    </script></head><body><form name="thumbs" enctype="multipart/form-data" method="post" action="">
    <input type="file" name="filepath" id="filepath" onchange="startRequest();"/>
    </form>
    <div id="div1" style="visibility:hidden;">
    </div></body></html>
    The ajax response is catching in a dummy.jsp
    <%=(String)request.getAttribute("filepath")%>
    corresponding action mapping
    <action path="/FilePathAction" type="actions.FilePathAction">
    <forward name="filepath" path="/dummy.jsp"/>
    </action>
    So plz help me to upload a file to the server from any PC.
    Iam searched alot but didnt get any solution.

    Plz help me soon if it possible so
    Iam in great need.
    I have worked alot but not worked out.
    Any help greatly appreciated

  • How to use connection pool in jsp/servlet ?

    I found I can "lookup" it in either java beans/servlets/JSP using JNDI. why?
    what is the best practice to use it in a jsp/servlet web app considering JNDI lookuping expensive?
    Thanks!
    Bo
    Edited by: BobXu on Nov 17, 2008 2:27 PM
    Edited by: BobXu on Nov 17, 2008 2:32 PM

    Huh?
    You can lookup a JNDI resource from anywhere in java code you want to. As long as you have a repository set up to search on :-)
    Of course whether that resource is available or not is a different matter. If you let the server set up the JNDI resource for you, then you can't run it standalone outside the server without something else setting the same thing up :-)
    So its not so much a limitation of beans, but just the environment you run the code in.
    Best practice? Don't write sql queries in JSP pages :-)
    For the rest you might consider the DAO pattern. Or ignore SQL altogether and let hibernate do the work there for you.
    Cheers,
    evnafets

  • Using a bean in a servlet

    In my application I am having:-
    1)- a table in my database which contains the details of the user profile.
    2)- a bean which contains the string variables for all the user details along with the getters and setters.
    3)- a servelet and a jsp.
    In servlet I want to fetch entire data of the table and want to assign the values to the setters of the bean.
    in jsp I want to call that bean and want to use its getters to display the entire profile of the user.
    I am finding compleatly unable to use the bean in the servlet, please help me out.

    hi,
    try like this..
    after fetching all of your datas
    store in setter method of the bean.
    pass it as session.setAttribute ( "beanname", bean);
    in jsp
    get that session attribute
    beanname b = (beanname) session.getAttribute ( "beanname" ) ;
    <%=b.getMethod ()%>

  • Managing blob images using ADF and JSF or struts

    Hello everyone. I am an ADF newbe and I am developing a web app. that has to manage (display, insert,update and delete) blob images from/to an oracle DB. I've seen the "howto" on image managing using intermedia and struts, but, for this new app I wanted to use JSF (something that is not mandatory) and, what is important is that the DB has already stored the images in blob format.
    Can anybody point me in the right direction please??? Is there any howtos on this subject???
    Thanks in advance.

    jfin wrote:
    but so far I have to say that I like the fact that I'll have to do very little
    System.out.println(<..../>....<>....</>).Assuming that you rather mean out.println() where out is the ServletOutputStream reference returned by HttpServletResponse#getOutputStream(), I can only agree with you. That's certainly not the way how JSP/Servlet code is to be written. The maintainability, extendability, reusability and testability would be far below the freezing point then. You need to write presentation logic in JSP files, not in Servlets and absolutely not in scriptlets inside a JSP.
    When you need to write presentation logic which may change per request, use JSTL and EL for that. Again, not scriptlets. For business and controlling logic, use Servlets. For transfer of data, use javabeans (DTO's, VO's). For data access logic, use DAO classes which are to be interacted by servlets.
    JSF removes the need for creating Servlets and using JSTL/EL in JSP files. You just have JSP pages with JSF tags for presentation and javabeans for the request values and backing beans for business logic.
    When would one use JSF over the other two? When Struts2? When Shale?And you ask that in a JSF forum? At least my opinion is predictable :)

  • Using databases and container events?

    I'm having trouble finding documents show how one should use databases and listen for container events? I'm using Berkley Java DB. I'll need all my remote object to have access to the database. How do I pass that in? Custom adapters? Also, when Tomcat shuts down I need to close the database, how would this be down? Custom adapters? So I may be answering my own question, but I'm asking cause I really don't see anything in the documentation that points this out. It really looks like I'd be using singletons and factories for this. I could register a Servlet or Servlet Context to listen for Tomcat events, but I figured it couldn't hurt to ask others using Blaze, as I'm very new to it. Thanks.

    So how would you tell Blaze to use this? Is there something you put into the config file? My thoughts on all this is to use PicoContainer to manage all services then create an adapter to inject all resources when creating remote objects. But this seems a little heavy if Blaze can do all this for me. The adapter seems like the injection point to me. Is that not what it's used for? Or is using it like that bad practice under Blaze? I've read all I can find on Blaze, so either it's missing docs, or I'm not finding them all. If I'm missing them, by all means let me know where to go. I don't want to ask questions that are already answered in documents else where.
    On Tue, May 20, 2008 at 10:51 AM, Mete Atamel <
    [email protected]> wrote:
    A new message was posted by Mete Atamel in
    General Discussion --
      Using databases and container events?
    I think it's mainly in JavaDocs but here's a sample I have where I check to make sure the HSQLDB is running as the BlazeDS starts up:
    import java.sql.Connection;
    import java.sql.SQLException;
    import flex.messaging.config.ConfigMap;
    import flex.messaging.services.AbstractBootstrapService;
    public class DatabaseCheckService extends AbstractBootstrapService
        // This is called right before server starts up.
        public void initialize(String id, ConfigMap properties)
            Connection c = null;
            try
                // Check that the database is running...
                c = ConnectionHelper.getConnection();
                // ... if yes return
                return;
            catch (SQLException e)
                System.out.println("DB is not running!");
            finally
                ConnectionHelper.close(c);
    // This is called as server is starting.
        public void start()
            // No-op
    // This is called as server is stopping.
        public void stop()
            // No-op
    View/reply at
    Using databases and container events?
    Replies by email are OK.
    Use the
    unsubscribe form to cancel your email subscription.
    "All that is necessary for the triumph of evil is that good men do nothing." - Edmund Burke

  • Use of Synchronized  in jsp/servlet

    Can any one explain me the use of Synchronized in servlet/jsp which is multithreaded Is this correct synchronized should be used only when we want to pritect Static variable as they have only one copy but in case of instance variable they have seperate copy for each instance so no point of synchronized.
    Thanks in advance

    Hello again,
    Take an external file for instance, you open a input stream to it and read data from it in your Java application. You can't have two threads reading at the same time, and one will likely block or throw an exception.
    A better example is when your threads need to communicate with each other. If they all communicate via a set of variables that can be read and written to by any of them, then they should be synchronized. You should know if your threads need to communicate with each other? If they do not, there is no need for synchronisation.
    What are your threads doing if you don't mind me asking?
    I have to admit, I have had little experience using threads, and I have never needed to use threads in JSP (I don ot directly use servlets).
    Regards,
    Darren

  • How to use a javaBean in a servlet without FORMS...

    Hi,
    I would like to use a javaBean in a Servlet.
    I know how you can do this with the code
    HttpSession session = request.getSession();
    in your servlet.
    However, by using this code you have to call the servlet by a FORM. Is it possible to call the servlet (which calls the javaBean) in your JSP file without a FORM?
    Greetings
    Tigi

    Thanks Anthony,
    I'm working with Tigi on the same project and now I can tell you that the problem is solved.
    request.getRequestDisptacher("/myServlet");hehe, you switched the 't' and the 'a'
    <%@ include file="/myServlet" %>this is the one we use :)
    But what is the difference between the first one and the last one? Now We are using the last one because that's the shortest :) not a pretty good reason huh :)
    cheers,
    Soep

  • Can I use SimpleFdkCredential() from within a servlet?

    I have a test program that logs in to content DB using SimpleFdkCredential, and works perfectly well run from the main() method of a Java class from within JDeveloper. When I try to login the same way from within the doGet() method of a servlet, doGet() hangs on the call to ManagersFactory.login() using the same SimpleFdkCredential that works in-process. The login() call doesn't throw any exceptions, it just sits there waiting[I presume], and never returns.
    Is it necessary to use S2SFdkCredential for any authentication that originates from a servlet invocation? It seems that SimpleFdkCredential should work in this instance as well.
    Thanks.

    Can you check the Content DB http node log (application.log) with debug log level set, to see if the request from the servlet for the RemoteLoginManager Web Service was received?
    I would also check that all libraries are present/accessible from servlet - and that there are no conflicts with existing libraries.
    Also, check the servlet log for anything strange.
    Finally, you could try remote debugging of your servlet .. e.g -Xdebug java option.
    -Matt.

Maybe you are looking for

  • Getting Error in BI_PROCESS_TRIGGER job

    Hi Gurus, We are getting the below error when we schedule the process chain BI_PROCESS_TRIGGER job.If we manually execute it is working fine Job started Step 001 started (program RSPROCESS, variant &0000000467441, user ID ALEREMOTE) NO_MORE_SPACE: Ca

  • I let my Macbook die and now it doesn't recognize old wifi connections and doesn't trust internet.

    Hi- I have often let my Mac die, while going to sleep etc, this is the second time that when I charge it back up and turn it on it doesn't work the same.  It doesn't remember the passwords of old wifi networks that I have told to "remember this netwo

  • Image does not open in CS6

    The image appears in the Camera Raw window. I click to open it and all that comes up in the workspace is the image's name/text but no image. When I click open in a new window I get a blank window with the same name. Mike

  • Can't Open Excel Files in iOS 6

    One of my co workers upgraded to the new iOS 6 last week and now they can't open some of the Excel files from their iPhone 4S.  I can open the file with no problem, I have iOS 5.1.1 iPhone 4S.  iOS 6 can open some of the excel files, but I know it ca

  • Strange syslog from Prime Infrastructure 2.1

    Been getting alot of these syslog messages. I think perhaps a system job is failing but I don't know where to start to troubleshoot. 09 03 2014 11:23:13 [pi-ip-address] <LOC7:ERRR> 09/03/14 11:23:13.484 ERROR [jobmanager] [seqtaskexecutor-12371] ERRO