How to implement use bean tag in servlet technology

hello,
i want to use application scope for variables in application . i know about use bean tag but i want to use servelet technology. how could this be done

The application scope corresponds to the servlet context. From your servlet, use getServletContext().getAttribute() and getServletContext().setAttribute().

Similar Messages

  • How to implement metadata keyword tags

    Can someone please advise me on how to implement meta keyword tag <meta name="keyword" content="..."> for individual community page? We have a set of keywords for each community page. I know we can just add the line above to base page layout if they are common keywords to all the community page but not sure whats the best way to add unique set of meta keyword tags to individual community page? FYI - We are using UCM for managing content for our site.

    I always did this using a property on the page object.
    1. Create a new property called "meta-keywords" and associate it to the community pages object through the global object property mapper utility.
    2. Edit your community page and add any keywords you desire.
    3. Write a custom tag for said property that takes a uuid as input (this way you can migrate and the tag remains the same.
    4. same idea works for any meta tag.
    Note: you are limited to 255 characters this way.
    Or you can probably code some kind of tag that reads from UCM as well, but i always did it the above way.
    Here is a tag example:
    public class MetaPropertyCurrentPage extends ATag {
         private OpenLogger log = OpenLogService.GetLogger(
                   OpenLogService.GetComponent(PTDebugHelpers.COMPONENT_PORTAL_COMMON),
                   "customizations.tag.standard.MetaPropertyCurrentPage");
         public static final RequiredTagAttribute UUID;
         public static final ITagMetaData TAG;
         static {
              TAG = new TagMetaData("currpageproperty",
                        "Displays the value of the property in the current page from the uuid.");
         UUID = new RequiredTagAttribute("uuid", "The UUID for the property you want to open.",
    AttributeType.STRING);
         @Override
         public ATag Create() {
              return new MetaPropertyCurrentPage();
         @Override
         public HTMLElement DisplayTag() {
              log.Info("Entering meta lookup");
              String objectid;
              String classid;
              HTMLElement result = new HTMLElementCollection();
              IEnvironment env = GetEnvironment();
              AActivitySpace owner = TaskAPIUICommon.GetEnvTypeObject(env);
              //get pageid
              int pageid = TaskAPIUICommunity.GetCurrentCommunityPageID(owner);
              //check if not a community page
              if (!TaskAPIUICommunity.IsCurrentPageCommunityPage(owner))
                   return result;
              //convert to objectid
              try
                   Object[] objectAndClassId = ((IPTMigrationManager)(((IPTSession)GetEnvironment()
                   .GetUserSession()).OpenGlobalObject(PT_GLOBALOBJECTS.PT_GLOBAL_MIGRATION_MANAGER,
                   false))).UUIDToObjectID(GetTagAttributeAsString(UUID));
                   objectid = objectAndClassId[PT_MIGRATION_OBJECT_COLS.PT_MOC_OBJECTID].toString();
                   log.Info( "found objectid" + objectid);
                   classid = objectAndClassId[PT_MIGRATION_OBJECT_COLS.PT_MOC_CLASSID].toString();
                   //check to make sure its a property
                   if (Integer.parseInt(classid) != PT_CLASSIDS.PT_PROPERTY_ID)
                        return new HTMLComment("UUID does not belong to a property");
              catch (Exception e)
                   log.Error(e, "error getting the objectid from the UUID.");
                   return null;
              //now get the property from it
              IPTSession session = (IPTSession)GetEnvironment().GetUserSession();
              IPTObjectManager objMgr = session.GetPages();
              IPTPage page = (IPTPage)objMgr.Open(pageid, false);
              log.Info("Page name: " + page.GetName());
              IPTQueryResult qresult = page.GetObjectProperties().GetSinglePropertyData(Integer.parseInt(objectid), PT_PROPIDS.PT_PROPID_PROP_VALUE);
              if (qresult.Data() != null)
                   IPTObjectManager objMgr2 = session.GetProperties();
                   IPTProperty prop = (IPTProperty)objMgr2.Open(Integer.parseInt(objectid), false);
                   String propName = prop.GetName();
                   log.Info("Property name is: " + propName);
                   String value = (String) qresult.Data()[1][0];
                   if (lang.equalsIgnoreCase(propLocale) && value != null && !value.equalsIgnoreCase(""))
                        result.AddInnerHTMLString("<meta name=\"" + propName + "\" content=\"" + value + "\" />");
              else
                   log.Info("Property Value not found.");
              return result;
         }

  • Can I use any Class in a Use Bean Tag of a JSP

    I have tried to modify the existing EditForm.java file and created a new Class File which changes the presentation(render method)in the Edit Form.
    can I use the new class as a Bean in the use bean tag of a JSP.

    You can use any class as part of the useBean tag. If you want to add your class to the list of available webbeans, you can add it to <jdev dir>\teamplates\webbeans.xml.

  • How to implement a connection pooling in servlet

    hi all,
    how to implement a connection pooling in servlet.i want to know how to implement it in tomcat in a struts based environment.
    any input to the topic is appreciated.
    Thanks
    Sudha

    Take a look at JNDI
    http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html

  • How do you use image tags

    How do you use Image tags. Thank you

    Hi John,
    Have you seen this video? It describes how to apply default image tags to your pictures, and then describes how to create new, custom tags. Is there something more specific that you're wondering about? I'd love to help!
    Cheers,
    Michael

  • How to implement this function in JSP/Servlet env?

    Hi all,
    I working on a project, it provides functionality to upload file using JSP/Servlet. In the first JSP page, there is file location and submit button. After user select a file to upload and click submit button, a message, like "sending file to XXXX", will be shown on the screen. Once uploading and validation are done on the server-side, a successful/error msg will be shown to user.
    Here I have a question for the "sending..." msg and the successful/error msg. They should be put in one jsp page or in two separate page? how to implement them?
    Thanks for any help!
    Tranquil

    For the sending message... Well, the thing is, when you click submit, it's sending the file to the server and the server is processing it, and this is all done before the "complete" page is sent to the server. So one would need to use some Javascript on the page before the actual submit happens to show some message. This is done on Ebay when you put something for sale, you can upload an image, and there is a little popup message telling you that it's uploading, and it is removed when the process is done. Now, I'm not sure the exact details of how this works, but my educated guess is this:
    1) The onsubmit function of the form checks that the file upload fields have a value (no need to popup a message if no file upload, since that's what usually takes the time, although it could just be assumed there is a file). If a file is to be uploaded, or just want to show the message anyway, a new popup window is opened with the window.open method and the "sending" message is shown (either written via Javascript or just load a small web page to the window).
    2) The popup window, since you can't transfer the window object from the form page to the next page, has to check window.opener for some value that the success/error page would have to set. The success/error page could use it's body onload function to set a variable in it's own window object to denote that the page is loaded. The popup window can use a looping check using setTimeout or setInterval in Javascript to check for window.opener.isLoadedVariable to be present, and if so, close itself.
    I've never done that, but I see no reason why it wouldn't work.

  • How to Implement jsp:useBean tags

    Hi,
    I hav a trouble with using the Tag jsp:useBean
    Actually im using Tomcat4.1 webserver'
    I created a java file and compiled that
    When i included that class file,The Jsp Compiler seeming me a error that the Required class in not found
    Actually wht my problem is that i cannot find out the storage locations for the corresponding files
    I know where to save the jsp
    but i need to know where to put the class file and its source.Bcz that one which i want to use in that tag{<jsp:useBean>}
    I want to know what should i do
    With Regards
    Ganesh B

    Beans are regular Java classes that follow particular conventions defined by the JavaBean's specification. The don't extend from a particular class, they aren't packaged in a particular package, and - germane to the question - they aren't located in a special place on the server. The classes which are loaded into the JSP by the <jsp:useBean> construct are located in the same location as other classes in a web application. They are located in the classes directory of the WEB-INF directory of the web application directory itself. Or, if you bundle your classes into a jar file, then the jar file will be located in the lib directory of the WEB-INF directory. In either case, remember to use packages for your classes including your beans.

  • Implementation of application scope in servlet technology

    hello,
    i want to define certain variable with application scope , in servlet technology how to do that

    Attributes can be stored in the ServletContext in the same manner as they are stored in the session.
    String x = "Stored Value";
    getServletContext().setAttribute("x", x);
    String y = (String) getServletContext().getAttribute("x");

  • How do I use a tag within a tag?

    I have a tag that takes a variable input that is produced from another tag. But I can't figure out how to use the output of one, as the input for another. I'm using the value produced as a value for a form. ex
    <input type="text" value="<x:tag var="<x:tag2/>"/>"/> is there a certain way to do this?

    You can't use JSP custom tags as attributes for other JSP custom tags.
    You can only use runtime expressions like <%= expr %> or in JSP2.0 ${expr}
    The snippet you have given looks ok, as the <input type="text"> is just HTML template text, and not a JSP custom tag.
    Your <x:tag> looks a little confused, as you have an opening and closing, and the quotes don't seem to match up with 'var="
    <input type="text" value="<c:out value="${username}"/>">

  • How we can use jsf tags in included jsp enclosed in subview tags

    Hello everybody,
    I am developing web app by using jsf. I am including a jsp page "header.jsp" into another jsp page "main.jsp". The header.jsp page is enclosed in jsf subview tag on main.jsp page. The header.jsp contains some static html code and some jsf tags like "outputText". When i added tag library url in header.jsp then my app was not even not initiating and i was getting following exception
    ERROR [UIComponentTag] Faces context not found. getResponseWriter will fail. Check if the FacesServlet has been initialized at all in your web.xml.
    16:22:16,890 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
    java.lang.NullPointerException
    at javax.faces.webapp.UIComponentTag.setupResponseWriter(UIComponentTag.java:929)
    at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:310)
    ....Now i removed jsf tag library url from included jsp "header.jsp" so now my app is running but only static html data is being displayed but the value in the jsf tag "outputText" is not being printed in the browser
    kindly help me. i would be very thankful....

    Your question has nothing to do with Sun Java System Directory Server.
    Please use the right forum(s).
    Thanks

  • Use bean tag

    Hi,
    I've used the usebean tag in my jsp, but while compiling it cannot lacate my bean. The bean is kept in the same folder as the jsp. What is the problem? Please help!
    regards

    Beans should be placed in WEB-APP/classes.
    e.g.a bean called MyBean in package a.b should be:
    WEB-APP/classes/a/b/MyBean.class

  • How do I use JMQ from a servlet?

    I need to satisfy the following requirements. Please follow the sequence (I dont have Rational Rose with me! :-))
    1.A end user sends a web request (for a servlet) through the browser.
    2.Servlet sends a message to a backend process via JMS.
    3.backend process does something and creates display data for the servlet.
    4.backend process sends a message containing this data back to the servlet via JMS.
    The stringent requirements are that step 2 and 4 have to be achieved using JMS. This is not negotiable! :-) Based on my limited knowledge of JMS, the way to achieve this is by
    1.Having a Destination (Queue/Topic) for which the backend process is the consumer and all servlet instances are producers.
    2.Or every request that the servlet receives, create a TemporaryQueue and send its name to the backend process through the message sent by the servlet. The servlet is the consumer of this queue and the backend process becomes the producer to send the display data to the servlet.
    Is anybody knowledgable enough in JMS, to tell me if this is likely to fail? Or if there is a better solution?

    Sounds reasonable to me. Take a look at the JMS javadoc for TopicRequestor
    or QueueRequestor. Same idea. The client receiving the first message gets
    the reply destination from the ReplyTo field in the incomming message.

  • How can i use twain from java servlet?

    dear all
    iam a web developer ,iam haviving now a task to search in point pf scanning image through web (Intranet) using java
    can any one tell where can i find resources how to deal with Twain using java (On web specially not from a desktop application)
    i hope u can help me
    Thanks in advance
    Yours,
    Amr
    Senior Java Web developer

    Hi,
    You can try a package named: JTwain, which is available at http://asprise.com/product/jtwain.
    JTwain supports all kinds of digital cameras and scanners. You can use Java to access, contorl digital cameras and scanners, and of course, to acquire images with flexible settings.
    The developers' guide is available @ http://asprise.com/product/jtwain/devGuide.php
    In the simplest case, one line of Java code can solve your problem.
    Good luck!

  • How to use HTML tags inside JSF pages

    I am creating a Menu using dataTable and outputLink in a JSF page.
    <div class="bodyarea">
    <div id="location">
    <ol>
    <h:dataTable value="#{menuItem.breadCrumb}" var="bread" >
    <h:column>
    <li>
    <h:outputLink id="crumbID" value="#{bread.menuLink}">
    <h:outputText id="crumpName" value="#{bread.menuLabel}" style="width: 165px;"/>
    </h:outputLink>
    <li>
    </h:column>
    </h:dataTable>
    </ol>
    </div>
    </div>
    I want to use <li> HTML tag as shown in code above before and after every <tr> tag formed, but when i run it and see view source, this is how it shows:
    NOTE: you can see it has thrown out of <table> tag itself.
    <div class="bodyarea">
    <div id="location">
    <ol>
    <li>
    </li>
    <table>
    <tbody>
    <tr>
    <td><a id="_id0:0:crumbID" href="/eApps/admin/loginPage.jsp?MenuItem=-1"><span id="_id0:0:crumpName" style="width: 165px;">Home</span></a></td>
    </tr>
    <tr>
    <td><a id="_id0:1:crumbID" href="/eApps/admin/loginPage.jsp?MenuItem=3~-1"><span id="_id0:1:crumpName" style="width: 165px;">HIM Admin</span></a></td>
    </tr>
    </tbody>
    </table>
    </ol>
    </div>
    </div>
    Can some one help me, how do i use HTML tags inside <h:dataTable>.
    Or is their any other way i should form my Menus, to fully utilize to HTML tags.
    Thanks
    Ravi

    Hello,
    You can embed the verbatim elements in your datatable, ie,
    <h:dataTable value="#{menuItem.breadCrumb}" var="bread" >
      <h:column>
        <f:verbatim><li></f:verbatim>
        <h:outputLink id="crumbID" value="#{bread.menuLink}">
          <h:outputText id="crumpName" value="#{bread.menuLabel}" style="width: 165px;"/>
        </h:outputLink>
        <f:verbatim></li></f:verbatim>
      </h:column>
    </h:dataTable>

  • I want to display BLOB image in JSP Using  html tags IMG src=

    GoodAfternoon Sir/Madom
    I Have got the image from oracle database but want to display BLOB image using <IMG src="" > Html tags in JSP page . If it is possible than please give some ideas or
    Send me sample codes for display image.
    This code is ok and working no problem here Please send me code How to display using html tag from oracle in JSP page.
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import="javax.swing.ImageIcon;" %>
          <%
            out.print("hiiiiiii") ;
                // declare a connection by using Connection interface
                Connection connection = null;
                /* Create string of connection url within specified format with machine
                   name, port number and database name. Here machine name id localhost
                   and database name is student. */
                String connectionURL = "jdbc:oracle:thin:@localhost:1521:orcl";
                /*declare a resultSet that works as a table resulted by execute a specified
                   sql query. */
                ResultSet rs = null;
                // Declare statement.
                PreparedStatement psmnt = null;
                  // declare InputStream object to store binary stream of given image.
                   InputStream sImage;
                try {
                    // Load JDBC driver "com.mysql.jdbc.Driver"
                    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
                        /* Create a connection by using getConnection() method that takes
                        parameters of string type connection url, user name and password to
                        connect to database. */
                    connection = DriverManager.getConnection(connectionURL, "scott", "root");
                        /* prepareStatement() is used for create statement object that is
                    used for sending sql statements to the specified database. */
                    psmnt = connection.prepareStatement("SELECT image FROM img WHERE id = ?");
                    psmnt.setString(1, "10");
                    rs = psmnt.executeQuery();
                    if(rs.next()) {
                          byte[] bytearray = new byte[1048576];
                          int size=0;
                          sImage = rs.getBinaryStream(1);
                        //response.reset();
                          response.setContentType("image/jpeg");
                          while((size=sImage.read(bytearray))!= -1 ){
                response.getOutputStream().write(bytearray,0,size);
                catch(Exception ex){
                        out.println("error :"+ex);
               finally {
                    // close all the connections.
                    rs.close();
                    psmnt.close();
                    connection.close();
         %>
         Thanks

    I have done exactly that in one of my applications.
    I have extracted the image from the database as a byte array, and displayed it using a servlet.
    Here is the method in the servlet which does the displaying:
    (since I'm writing one byte at a time, it's probably not terribly efficient but it works)
         private void sendImage(byte[] bytes, HttpServletRequest request, HttpServletResponse response) throws IOException {
              ServletOutputStream sout = response.getOutputStream();
              for(int n = 0; n < bytes.length; n++) {
                   sout.write(bytes[n]);
              sout.flush();
              sout.close();
         }Then in my JSP, I use this:
    <img src="/path-to-servlet/image.jpg"/>
    The name of the image to display is in the URL as well as the path to the servlet. The servlet will therefore need to extract the image name from the url and call the database.

Maybe you are looking for

  • Hard drive failure, new hard drive won't boot

    Toshiba Satellite A665 I bought this laptop 14 months ago, last month the laptop refused to boot. It would say: Isolinux disk error 05, ax4250, drive 9f Boot failed Often times on boot it would just show the black screen with a blinking underscore. I

  • Use MacBook as monitor for G4

    It would save me a lot of desk space if I could use my MacBook as the monitor for my G4. I connected the two by firewire but I couldn't run protected programs like Photoshop.

  • Remapping F9- f12 keys on Aluminum Keyboard for Final Cut Pro 6

    I'm working through the Apple Pro Training book, "FCP 6: Professional Editing in Final Cut Studio 2", and one of the first things the book recommends is to remap the F9 thru F12 keys for FCP functions. However, I have the new Apple thin aluminum exte

  • Transporting holiday calendar gives export error

    I have changed settings for a holiday calendar and I am trying to transport the calendars to my test system. But in the process I get an export error saying "scrap char in NUMC field found in TFAIT.VON." Does anybody know what the issue might be and

  • Vim powerline in not shown

    I am trying to use powerline in vim (from https://github.com/Lokaltog/powerline). So I installed the "python-powerline-git" package from AUR with yaourt. I also added the line let $PYTHONPATH='/usr/lib/python3.4/site-packages' to my vimrc to solve an