How to set  an object in request scope in  a jsp uysing  jstl

I usally use scriptlet in jsp to set an object in request is
there a way to do this using jstl
instead of this
<%request.setAttribute("test",myObject);%> I want to use tag ?

The <c:set> tag should be useful...
Of course if you can access it as a JSTL variable it IS already an attribute in scope.

Similar Messages

  • How to set a object value bound to a session to JavaScript variable

    In a JSP, I store an object value in a HttpSession and I also write a Javascript function to display something on the screen. I need to use the Javascript function to display the object value which is stored in the session. How to set the object value to variable of the JavaScript function. Thanks.

    I write a class JavaScriptHelper to convert the object value to variable of the JavaScript;
    1.get the data to a javabean from database;
    2.convert the data to variable of the JavaScript as a String ;
    3.store the object in a HttpSession or Httprequest ;
    4.use in Jsp get the String (variable of the JavaScript )
    YourBean bean = (YourBean) request.getAttribute("model");
         if (bean != null) out.println(bean .getJsCode())
    convert function,(this is only for the matrix):
    public static String formatJsCode(Vector vector) {
    String sJsCode = "";
    //get js head
    sJsCode = getJsHeader();
    //define js array;
    sJsCode += "var data=new Array();\n";
    Vector v = null;
    String sTemp = "", sLine = "";
    for (int i = 0; i < vector.size(); i++) {
    v = (Vector) vector.get(i);
    sLine = "";
    for (int j = 0; j < v.size(); j++) {
    sTemp = (String) v.get(j);
    //replace " to \"
    sTemp = sTemp.replaceAll("\"", "\\\\\\\"");
    //escape Html Tag
    //sTemp = StringUtil.escapeHTMLTags(sTemp);
    //replace \r\n to <br>
    sTemp = sTemp.replaceAll("\r\n", "<br>");
    if (j != 0)
    sLine += ",";
    sLine += "\"" + sTemp + "\"";
    sJsCode += "data[" + i + "]=new Array(" + sLine + ");\n";
    //get js foot
    sJsCode += getJsFooter();
    return sJsCode;
    public static String getJsHeader(){
    return "<script language=\"JavaScript\">";
    public static String getJsFooter(){
    return "</script>";
    }

  • How to set a Object value by JDI

    How to set a Object value using JDI?
    For example:
    class User{
      private String name;
      private String id;
    set and get method;
    public static void main(String[] args) throws Exception {
            VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
            List<AttachingConnector> connectors = vmm.attachingConnectors();
            SocketAttachingConnector sac = null;
            for (AttachingConnector ac : connectors) {
                if (ac instanceof SocketAttachingConnector) {
                    sac = (SocketAttachingConnector) ac;
                    break;
            if (sac == null) {
                System.out.println("JDI error");
                return;
            Map<String, Connector.Argument> arguments = sac.defaultArguments();
            Connector.Argument hostArg = arguments.get("hostname");
            Connector.Argument portArg = arguments.get("port");
            hostArg.setValue(HOST);
            portArg.setValue(String.valueOf(PORT));
            vmMachine = sac.attach(arguments);
            List<ReferenceType> classesByName = vmMachine.classesByName(CLSNAME);
            if (classesByName == null || classesByName.size() == 0) {
                System.out.println("No class found");
                return;
            ReferenceType rt = classesByName.get(0);
            List<Method> methodsByName = rt.methodsByName(METHODNAME);
            if (methodsByName == null || methodsByName.size() == 0) {
                System.out.println("No method found");
                return;
            Method method = methodsByName.get(0);
    I will connect to server and monitor the remote server JVM , There is a object of User, I want to change its value by the Java Debugger Interface by client.
    so how to set its value by the client, and I can not got the User bean at client.
    I know the basic type filed value changed as follows:
    Value newValue = vmMachine.mirrorOf("change var value");// this field is a string.
    stackFrame.thisObject().setValue(field, newValue);
    But a Object , how can I change its value.
    Thanks Advanced.

    ObjectReference.setValue() is the method for chaining the value of an Object's field. First you need to find the specific Object you want to change, though.
    /Staffan

  • How to set Principal object?

    Hello,
    I have two web applications. The "app1" is the one we are developing and retrieving the Principal object. The "app2" is a black box web application which we have no way to modify. We can only add parameters in web.xml. The business flow is that once the Principal object is retrieved in "app1", the "app1" calls "app2". The "app2" is looking for User_Principal object. The document says "USER_PRINCIPAL = (The user name is retrieved from a call to getUserPrincipal().getName() on the HttpServletRequest object for the current request in a servlet or JSP)". If I understand this correctly, the "app2" is going to look for "HttpServletRequest". How can the "app1" set Principal object so that "app2" can retrieve it from "HttpServletRequest"? As far as I know there is not "setUserPrincipal()" method in "HttpServletRequest". So the app1 cannot use "HttpServletRequest".
    Thanks in advance,
    Mustafa

    The UserPrinciple is set by the server after the user has been successfully authenticated. You should force the user to login to the second application using the <security-constrain> entry in web.xml. If your user has already been authenticated in your first application than make sure that you have the Realm the user is authenticated to available for both web apps.

  • Storing Objects in Request Scope

    Hello,
    I'm trying to pass an object in the request scope between a JSPDynPage and the associated JSP however the object is always null. If I store it in the session I am able to retrieve it.
    Could anyone assist in how to do this?
    My code is as follows, thanks and regards.
    public class MyClass extends PageProcessorComponent {
      private String redirectToPage = "";
      private static final String INITAL_PAGE = "initialpage.jsp";
      private static final String SECONDARY_PAGE = "secondarypage.jsp";
      private static final String BEAN_ALIAS = "myBean";
      public void doProcessBeforeOutput() throws PageException {
        if (redirectToPage == null || redirectToPage.equals("")) {
          this.setJspName(INITAL_PAGE);
        } else {
          this.setJspName(redirectToPage);
      public void onMyButtonEvent (Event event) {
        redirectToPage = SECONDARY_PAGE;
        MyBeanClass myBean = new MyBeanClass();
        IPortalComponentRequest componentRequest = (IPortalComponentRequest)getRequest();
        componentRequest.putValue(BEAN_ALIAS, myBean);
    secondarypage.jsp:
    <%@ page session = "true"%>
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <jsp:useBean id="myBean" scope="request" class="MyBeanClass " />
    <hbj:content id="myContent">
      <hbj:page title="myTitle">
       <hbj:form id="myForm">
         <% if (myBean != null) {
              out.println("null");
            } else {
              out.println("not null");
         %>
       </hbj:form>
      </hbj:page>
    </hbj:content>
    output on the page is always "null" ??

    Hi,
    Thanks for your posts... the null logic was actually a typo.
    I've solved the problem myself - basically I think the <jsp:useBean doesn't work as I expect it (that is automatically obtain the handle to the bean):
    MyDynPage.java:
    package com.my;
    import com.sapportals.htmlb.*;
    import com.sapportals.htmlb.enum.*;
    import com.sapportals.htmlb.event.*;
    import com.sapportals.htmlb.page.*;
    import com.sapportals.portal.htmlb.page.*;
    import com.sapportals.portal.prt.component.*;
    public class MyDynPage extends PageProcessorComponent {
      public DynPage getPage(){
        return new MyDynPageDynPage();
      public static class MyDynPageDynPage extends JSPDynPage{
        public void doInitialization(){
        public void doProcessAfterInput() throws PageException {
        public void doProcessBeforeOutput() throws PageException {
              IPortalComponentRequest componentRequest = (IPortalComponentRequest)getRequest();
              componentRequest.putValue("myRequestParam", "My Request Param Value");
              MyBean myBean = new MyBean("My Bean Title Value");          
              componentRequest.putValue("myBean", myBean);
             this.setJspName("myJSP.jsp");
    MyBean.java:
    package com.my;
    import java.io.Serializable;
    public class MyBean implements Serializable {
         private String txtTitle;
         //setters
         public void setTxtTitle(String txtTitle) { this.txtTitle = txtTitle; }
         //getters
         public String getTxtTitle() { return this.txtTitle; }
         public MyBean(String txtTitle) { //constructor
              this.txtTitle = txtTitle;
    myJSP.jsp:
    <%@ page session = "true"%>
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <jsp:useBean id="myBean" scope="request" class="com.my.MyBean" />
    <hbj:content id="myContext" >
      <hbj:page title="PageTitle">
       <hbj:form id="myFormId" >
        <%
               String myRequestParam = (String)componentRequest.getValue("myRequestParam");
              out.println("myRequestParam: " + myRequestParam + "<br>");
              if (myBean == null) {
                   out.println("myBean is null<br>");
              } else {
                   out.println("myBean is not null<br>");
                   out.println(myBean.getTxtTitle() + "<br>");
              com.my.MyBean myOtherBean = (com.my.MyBean) componentRequest.getValue("myBean");
              if (myOtherBean == null) {
                   out.println("myOtherBean is null");
              } else {
                   out.println("myOtherBean is not null<br>");
                   out.println(myOtherBean.getTxtTitle() + "<br>");
        %>
       </hbj:form>
      </hbj:page>
    </hbj:content>
    The output is:
    myRequestParam: My Request Param Value
    <b>myBean is null</b>
    myOtherBean is not null
    My Bean Title Value
    It appears that you can save objects in the request scope however you need to manually retrieve them. I'm pretty sure that this is not the case in other J2EE servers as the <jsp:useBean tag should imply that I want the bean retrieved from the scope automatically or created if it's null.
    However the use of the <jsp:useBean appears to work correctly/as expected when using the session scope.
    Thanks for your assistance.
    DSR

  • How to persist a data in request scope

    Hi All...
    I am using JDeveloper Studio Edition Version 11.1.1.0.2.In my managed bean (backing bean scope), I have a variable say " private loginname;" with a global scope and corresponding getter and setter methods inside the backing bean.How can I persist my data in request scope not using a session variable.
    Thanks in advance
    Dinil Mithra

    Hi all,
    I need to access the data in the request scope( Not in session scope ). ie, after the command button's action or action listener ,I loose the persistence of my variable.But the same time persistence of the textfield exists.I need to implement the persistence like textbox or ADF component
    Thanks for your response
    Dinil Mithra
    Edited by: Dinil Mithra on May 21, 2009 1:25 AM

  • How to set an object in attribute using tags

    Hello.
    I know you can do this <% request.setAttribute("someName", Object); %>
    But i am wondering if there is a jsp , jstl tag which can do the same thing? Also where I can give the scope.
    I would like to do something like this <jsp:someTag name="someName" value=${variable} scope="request" />
    Thanks in advance.

    I think you can use
    <c:set var="articleList" value="${advertises}" scope="session" />But this doesnt work. Any ideas?

  • How to set the attributes of request in JSF Programming

    Hi All,
    for setting the attribute values for session, we do something like below.
    setValue("#{sessionScope.PREFERED_TOTALDAYS}",request.getParameter("txtDays")!=null?request.getParameter("txtDays"): ""+jobRowSet.getInt("PREFERED_TOTALDAYS"));
    Now my query is for setting the attribute values of request what is the code I need to use??
    thanks,
    sudhakar

    Just replace "sessionScope" with "requestScope". That will set the attribute request scope.
    Regards
    -Jayashri
    Creator team.

  • Alignment tool - how to set reference object?

    I am new to Flash but have used Illustrator and InDesign for years. I am wondering if someone can explain how to set the reference object by which all other objects are aligned; e.g. Illustrator ->select all objects then a second click on the reference object and all other objects take their cue.
    InDesign you lock the reference object and that determines the rest.
    In Flash it seems that either both objects move or the one that I wish to remain in position jumps rather than the other way around.
    Thanks

    I don't know if you can set a reference object in Flash.  I have always just followed the general rule of aligning into the direction where the alignment basis would not move... meaning if I am aligning to the left, then the leftmost item I would select would be the reference, and if need be I would move other objects to the right of it first.

  • Set the value of a object in request scope

    I have the object in my req scope. I need to set value to one of the object attributes if that attribute is blank. How can I set its value.
    <c:set var="benefitVO" value="${requestScope.BenefitVO}" />I need to set the following Object attribute value, if it is blank.
    something like --- > benefitVO.setBnftCd("asdf");
    How can I set it using JSTL tags?
    any ideas
    Thanks

    I need to set value to one of the object attributes if that attribute is blank.This is some kind of a default value that you want, then? If so then just take care of that when you output it. Use <c:if>, and if the attribute is blank then output the default value, otherwise output the attribute.
    Or have the servlet that created that request attribute take care of that requirement.

  • How to use a JavaBean with request scope from one page to other page

    Hi,
    I want to use in one jsp file a javabean with scope of request for it, I use:
       <jsp:useBean id="entry" class="jsps.SaleEntry" scope="request" />and after in that page I make operations with it using the jsp:setProperty and jsp:getProperty operations
    My question is that if I want to get the result of that javabean in the following page, Have I to record the javabean doing : request.setAttribute(""objectId",id) and then in the following jsp page I can rescue the object doing: SaleEntry sE=(SaleEntry) request.getAttribute("objectId") ???
    or in the contrary, only using jsp:setProperty the information is available to recover it in the following jsp doing : SaleEntry sE=(SaleEntry) request.getAttribute("objectId") because setProperty records the information without need of doing : request.setAttribute(""objectId",id). ????
    Thanks with anticipation and sorry if it is a silly question but I am beginner in the use of JavaBeans

    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

  • CRMD_ORDER: how to set default values for Requester and Change Manager

    Hello Folks,
    how do I set default values in TA crmd_order?
    I drew my organizational hierarchy using TAs bp and ppoma_crm.
    When a new Change Request (e. g. SDHF) is created, I want the four roles (Requester, Change Manager, IT Operator and Developer) to be set automatically, not manually.
    Both Requester (= Key User) and Change Manager are derivable. I did not find anything in SPRO neither in the OSS neither here.
    Points will be rewarded as a matter of course!
    Thanx in advance!

    Hi Dirk,
    look for Define Access Sequence & Define Partner Determination Procedure in SPRO and read the IMG Activity Documentation. You can find it in the Service Desk config, but it works for the other transaction types too.
    Basically, you create Access Sequences where you tell the Partner Determination Procedure where to look for the values for the Partner Function fields.
    The Access Sequence can use lots of sources for the information, including your org structure.
    regards,
    Jason

  • How to set default object placement & wrap for drag-and-dropped files

    I am working on a document into which I need to drag-and-drop a number of files from the Finder: JPGs, PDFs, and so on. Each time I drag a file into Pages, by default its placement is set as "Floating (doesn't move with text)" and "Object causes wrap" is active.
    I would much prefer that the default settings be "inline" and "object does not cause wrap," so my drag-and-dropped images will appear within the text and move with it.
    Is there a way to change this default setting?

    Niel's suggestion is good. You might also try posting your question in the Tiger Server forums. I'm sure Tiger Server has several ways of dealing with this.

  • How to set Link object type to grid column??

    Hello friends ,
                    I m using C# language. I want to set LinkedObjectType to the grid columns.So how can I set the Linked Obj type to the grid column?
    Reguards ,
      Mithun

    Hi,
    it should look like this.
    oGrid.Columns.Item(ColUID).Type = BoGridColumnType.gct_EditText;
    EditTextColumn col = (EditTextColumn)oGrid.Columns.Item(ColUID);
    col.LinkedObjectType = "2"; // Link to BusinessPartner
    lgDavid

  • How to set an object to 100% width now that Muse no longer has the button?

    I'm trying to set a slideshow to 100% width like the tutorials constantly talk about, but that is no longer possible in the latest version of Muse. The button is gone. So how do you do it? And why did Adobe remove the 100% width button? They seemed proud of it when it was released as a new feature.

    Hi,
    The 100% width option is available for the slideshow widget. But to use it in your slideshow, make sure you have selected the "Hero Image" of the slideshow and then click on the button of the 100% width option.
    Please refer to this screenshot :- http://prntscr.com/567j41
    Hope this helps
    Regards,
    Rohit Nair

Maybe you are looking for

  • ICloud locked phone with no contact details.

    I have an iPhone with an iCloud account already logged in, the phone has been erased so I don't have an email to contact the owner through, the seller of the phone will not reply to any of my messages so I have no idea of how to fix this phone.

  • Error in content conversion

    Message:(Receiver Channel) 0.Root 1.->Header 2.node 1->Record(1..n) 2.BillNo 2.ByersName 2.Nameofgoods 2.Lineofbilling(1..n) 3.line1 3.line2 Receiver channel parameters: Recordsetstructure: Header,Record,Lineofbilling Header.fieldNames---node Header.

  • How do i add recordsets to a .dwt.asp-generated page

    help - i am at wits end..... below is code for a page (test3.asp) based on a template called "catalogue.dwt.asp". i need various recordsets on various pages based on this template. f i try to add a recordset to test3.asp, i'm told "making this change

  • Nokia 5130 mobile saved messages are not visble no...

    Nokia 5130 mobile saved messages are not visble not but still show in memory details, my mobile just restrated and with i turn back it on my saved messsages were not visible please help on that

  • Xorg.conf warnings and errors (hotplugging)

    Does my xorg.conf look ok? Just wondering how to fix the warnings and errors in it. http://pastebin.com/d7be45a5 Heres my xorg.conf too. http://pastebin.com/de9d8cf7 Last edited by Breakage (2009-01-16 21:22:28)