Tiles Within JSP Question

I have a JSP that has this line...
<img src="<tiles:getAsString name='imgName'/>" />
I get "weird" results however, when I call this JSP. The controller class that I had called (that calls this JSP) gets called a second time for some odd reason. If I put in a hard-coded string inside src then I don't have this problem. It seems like a very bizaare thing to me but that's what's happening. Note that if I put the line <tiles:getAsString name="imgName"/> outside of the src attribute then I don't have this problem either.
Any help would be GREATLY appreciated.

Thanks, that thread was informative. I thought it might help to use a base tag to set the url for the page, but I'm still baffled as to how the getServletContext().getRequestDispatcher() works and why this:
<p>getServletContext().getRequestDispatcher("/welcome.jsp")
<p>(from within the servlet at /WEB-INF/classes/Login.class) displays the welcome.jsp page in the browser but you look into the location bar and you see the servlet path "/servlet/Login".
<p> thanks.

Similar Messages

  • How can we call java control source methods within jsp

    Hi guys!
              How can we access java control source methods that are defined in java control projects within jsp.I am getting error when I tried to call java control source's methods in scriptlet of JSP page.Any help/suggestion is appreciated.
              Thanks
              -Chandu

    Uh, what?
    (And you are sure that it's not a Weblogic-specific question?)

  • Can EJB's be called from within JSP pages?

    Hi,
    (This is a general question, not necessarily related to OAS in any way...)
    I have read/heard conflicting reports pertaining to calling EJBs from within JSP pages.
    Can anyone tell me if it's possible to reference an EJB session bean from a JSP page? Can anyone point me to some documentation on the topic?
    Any help would be appreciated. Thanks!
    David Christopher
    [email protected]

    Hi,
    Check the following code: http://www.jguru.com/jguru/faq/view.jsp?EID=5314 for ejb example.
    -Ruchi
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Davidc:
    Hi,
    (This is a general question, not necessarily related to OAS in any way...)
    I have read/heard conflicting reports pertaining to calling EJBs from within JSP pages.
    Can anyone tell me if it's possible to reference an EJB session bean from a JSP page? Can anyone point me to some documentation on the topic?
    Any help would be appreciated. Thanks!
    David Christopher
    [email protected]<HR></BLOCKQUOTE>
    null

  • Which forum should I use if I have JSP questions?

    Hi, pals!
    Which forum should I use if I have JSP questions?
    Cheers,
    George

    http://forum.java.sun.com/forum.jsp?forum=45

  • WLS 7 JSP Questions

    Hi all, a couple of questions.
              WLS 7.001 (think it 001, maybe 01, whatever, it has the first SP I'm pretty
              sure), on W2K (dev) and Solaris 8 (deploy).
              Currently our app is deployed in "exploded" form within WLS, for
              developement, but will be deployed as a single EAR in production.
              Whenever we restart WLS, it seems to need to recompile the JSP as it first
              sees them, rather than taking advantage of the fact that they were compiled
              "last time". Once compiled, the system seems pretty quick, but the JSP
              compiles really crush any built up momentum.
              Is there a way around this? A way for it to not recompile "unchanged" JSPs
              after the sever is restarted?
              Second, what is the Best Practice on how to pre-compile the JSPs, so this
              can be eliminated completely. Does anyone have a good document on how to
              create a WAR filled with pre-compiled JSPs? Is there an ANT task that only
              pre-compiles the changed JSPs during a build?
              I know that there is a "compile JSPs on deploy" option, but that's just not
              practical. Our site has almost 3000 JSPs, and the deploy would just be
              eternal. Worse, the system must "re-deploy" the application whenever WLS
              starts up, which means a recompile, and that's simply not practical.
              Thanx for any advice you can provide. (Yes, I know we have a lot of JSPs,
              but that's not going to change soon...)
              Best Regards,
              Will Hartung
              ([email protected])
              

              Try to set working dir or similar in your weblogic.xml. You can use admin console
              to set/edit it and make the modified descriptors persistent.
              "Will Hartung" <[email protected]> wrote:
              >Hi all, a couple of questions.
              >
              >WLS 7.001 (think it 001, maybe 01, whatever, it has the first SP I'm
              >pretty
              >sure), on W2K (dev) and Solaris 8 (deploy).
              >
              >Currently our app is deployed in "exploded" form within WLS, for
              >developement, but will be deployed as a single EAR in production.
              >
              >Whenever we restart WLS, it seems to need to recompile the JSP as it
              >first
              >sees them, rather than taking advantage of the fact that they were compiled
              >"last time". Once compiled, the system seems pretty quick, but the JSP
              >compiles really crush any built up momentum.
              >
              >Is there a way around this? A way for it to not recompile "unchanged"
              >JSPs
              >after the sever is restarted?
              >
              >Second, what is the Best Practice on how to pre-compile the JSPs, so
              >this
              >can be eliminated completely. Does anyone have a good document on how
              >to
              >create a WAR filled with pre-compiled JSPs? Is there an ANT task that
              >only
              >pre-compiles the changed JSPs during a build?
              >
              >I know that there is a "compile JSPs on deploy" option, but that's just
              >not
              >practical. Our site has almost 3000 JSPs, and the deploy would just be
              >eternal. Worse, the system must "re-deploy" the application whenever
              >WLS
              >starts up, which means a recompile, and that's simply not practical.
              >
              >Thanx for any advice you can provide. (Yes, I know we have a lot of JSPs,
              >but that's not going to change soon...)
              >
              >Best Regards,
              >
              >Will Hartung
              >([email protected])
              >
              >
              >
              

  • Tile Based Game Questions

    Hi, I know there are tons on posts about this topic, but I can not find the answer to my questions.
    First, how would I go about moving the world around so the char is always in the center or near center of the screen? Do I have to have some sort of offset or something?
    Second, how would I have efficient collision dection? I use the following code for movement...
    public class worldTravelPanel extends JPanel implements MouseListener
         mapGround mapGround = new mapGround();
         mapWall mapWall = new mapWall();
         mapRoof mapRoof = new mapRoof();
         mapDoor mapDoor = new mapDoor();
         mapNPC mapNPC = new mapNPC();
         Point2D start, end;
         double x, y, animationSet;
         Timer timer = new Timer();
         public worldTravelPanel()
              mapGround.loadImages("town");
              mapGround.loadTiles("olatheMap");
              mapWall.loadImages("town");
              mapWall.loadTiles("olatheMap");
              mapDoor.loadImages("town");
              mapDoor.loadTiles("olatheMap");
              mapNPC.loadImages("generic");
              mapNPC.loadTiles("olatheMap");
              mapRoof.loadImages("town");
              mapRoof.loadTiles("olatheMap");
              x = programWidth / 2;
              y = programHeight / 2;
              animationSet = 7.0;
         class moveTask extends TimerTask
              Point2D start = new Point2D.Double(hero.location[0][0], hero.location[0][1]);;
              Point2D end = new Point2D.Double(hero.location[1][0], hero.location[1][1]);
              double distance = start.distance(end);
              public void run()
                   if(((Math.abs(start.getX() - end.getX()) < 0.5) && (Math.abs(start.getY() - end.getY()) < 0.5)) && start != end)
                        start = end;
                   else if (start != end)
                        double distance = start.distance(end);
                        x = (end.getX() - start.getX()) / distance;
                        y = (end.getY() - start.getY()) / distance;
                        hero.location[1][0] = (int)(start.getX() + x);
                        hero.location[1][1] = (int)(start.getY() + y);
                        checkForCollision();
                        repaint();
                   else
                        hero.location[0][0] = (int)start.getX();
                        hero.location[0][1] = (int)start.getY();
                        timer.cancel();
              public void checkForCollision()
                   int tempX = (int)(hero.location[1][0] / 32);
                   int tempY = (int)(hero.location[1][1] / 32);
                   boolean wallCollision = false;
                        if(end.getX() > start.getX())
                        if(mapWall.currentWallMap[tempY][tempX + 1] != 00)
                             wallCollision = true;
                   else if(end.getX() < start.getX())
                        if(tempX <= 1)
                             tempX = 1;
                        if(mapWall.currentWallMap[tempY][tempX - 1] != 00)
                        wallCollision = true;
                   if(end.getY() < start.getY())
                        if(mapWall.currentWallMap[tempY + 1][tempX] != 00)
                        wallCollision = true;
                   else if(end.getY() > start.getY())
                        if(tempY <= 1)
                             tempY = 1;
                        if(mapWall.currentWallMap[tempY - 1][tempX] != 00)
                        wallCollision = true;
                   if(wallCollision == true)
                        System.out.println("Wall Collision: " + tempY + ", " + tempX);
                        //end.setLocation(hero.location[1][0], hero.location[1][1]);
                        //start.setLocation(hero.location[1][0], hero.location[1][1]);
                        start.setLocation(start.getX() + x, start.getY() + y);
                        x = start.getX();
                        y = start.getY();
                   else if(mapDoor.currentDoorMap[tempY][tempX] != 00)
                        System.out.println("Enter Door: " + mapDoor.currentDoorMap[tempY][tempX]);
                        hero.map = "olatheMap";
                        changeMap();
                   else if(mapNPC.currentNPCMap[tempY][tempX] != 00)
                        System.out.println("NPC Collision");
                        start.setLocation(start.getX() + x, start.getY() + y);
                        x = start.getX();
                        y = start.getY();
                   else
                        start.setLocation(start.getX() + x, start.getY() + y);
                        x = start.getX();
                        y = start.getY();
                   public void changeMap()
                   mapGround.loadTiles(hero.map);
                   mapWall.loadTiles(hero.map);
                   mapDoor.loadTiles(hero.map);
                   mapNPC.loadTiles(hero.map);
                   mapRoof.loadTiles(hero.map);
                   x = programWidth / 2;
                   y = programHeight / 2;
                   start.setLocation(x, y);
                   end.setLocation(x, y);
         protected void paintComponent(Graphics g)
              g.clipRect(0, 0, programWidth, programHeight);
              g.setColor(Color.white);
              g.fillRect(0, 0, programWidth, programHeight);
              mapGround.drawGround(g);//Floor Layer
              mapWall.drawWall(g);//Wall Layer
              mapDoor.drawDoor(g);//Interaction Layer 1
              mapNPC.drawNPC(g);//Interaction Layer 2
              charHero[(int)animationSet].paintIcon(this, g, (int)x, (int)y);
              mapRoof.drawRoof(g);//Roof Layer
         //Begin Mouse Listener Block
         public void mouseClicked(MouseEvent e){}
         public void mousePressed(MouseEvent e){processMouseMotion(e);}
         public void mouseReleased(MouseEvent e){}
         public void mouseEntered(MouseEvent e){}
         public void mouseExited(MouseEvent e){}
         private void processMouseMotion(MouseEvent e)
              if(e.getModifiers() == MouseEvent.BUTTON1_MASK)
                   hero.location[0][0] = (int)x;
                   hero.location[0][1] = (int)y;
                   hero.location[1][0] = (int)(e.getX() / 32) * 32 + 3;//Centers hero is tile
                   hero.location[1][1] = (int)(e.getY() / 32) * 32;//Centers hero is tile
                   timer.cancel();
                   timer = new Timer();
                   timer.schedule(new moveTask(), 0, 10);
         //End Mouse Listener Block
    }Thanks for any and all help!
    Ryltar

    I answered this here:
    http://forum.java.sun.com/thread.jsp?forum=406&thread=535480&tstart=60&trange=15
    If that doesn't work for you, ask some more specific questions and I'll try to give more help.

  • Html fragments within JSP code

    Hi
    I'm not a developer, but need to create some JSP pages to sit within the site page structure.
    I was originally told i had to strip out the following tags....
    <html> <head> and <body>
    And just use the bare bones layout tags.
    But i have created a small piece of functionality that relies on calling a javascript function from within the <body> tag....
    Is it so bad to leave in this <body> tag in the page fragment?
    I'm not even sure if this is the standard way to create JSP pages but if anyone can offer any advice that would be great.

    There is no requirement to strip out the html or body tags, or any tags for that matter. In fact, JSP isn't specific to HTML content. JSPs can be used for XML, WML, or some proprietary client content markup.
    JSP pages are simply dynamically generated pages to define it quite unofficially and non-technically.
    Your topic seems to be one of web content development. This forum is dedicated to the Web Application Framework. I'm not sure what your challenges are, but you will likely find more successful guidance on a forum that is focused on web design or general JSP technology.
    But to answer your question, you can keep your html based tags in the JSP.
    craig

  • Sessions within JSP's

    I have a JSP with a number of beans declared as session beans.
    I then include (JSP:INCLUDE) a servlet which then tries to access one of the session beans.
    To check how things are going I do the following within the servlet:
         // Retreives session Object
         HttpSession session = req.getSession(true);
    if (session == null) {
    printTrace("Failed to get the Session!");
    if (session.isNew()) {
    printTrace("A new session was created!");
    I always get the "A new session was created!" reply.
    When I return to the JSP, any information that had been set up in the servlet does not appear in the session.
    It appears that the JSP has created another session, different from the servlets session and all the beans are in their initial state.
    QUESTION:
         Could someone point me towards some information on when the session is created in a JSP?
    Regards
    Phil

    I have a JSP with a number of beans declared as
    session beans.
    I then include (JSP:INCLUDE) a servlet which then
    tries to access one of the session beans.
    To check how things are going I do the following
    within the servlet:
    // Retreives session Object
    HttpSession session = req.getSession(true);
    if (session == null) {
    printTrace("Failed to get the
    ("Failed to get the Session!");
    if (session.isNew()) {
    printTrace("A new session was
    ("A new session was created!");
    I always get the "A new session was created!" reply.
    When I return to the JSP, any information that had
    been set up in the servlet does not appear in the
    session.
    It appears that the JSP has created another session,
    different from the servlets session and all the beans
    are in their initial state.
    QUESTION:
    Could someone point me towards some information on
    when the session is created in a JSP?
    Regards
    PhilTry HttpSession session = req.getSession(false);
    When you pass true, it will create a new session if one does not exist. thats why you get "A new session was created!" all the time.
    regards
    Stef

  • Accessing classes in web-inf/classes within JSP

    hi,
    i know this is probably a very basic question..or nobody would ever do something like this..but I'mn curious:
    i have a class Car.class in the WEB-INF/classes directory and I want to access it from withing JSP : <% Car c = new Car(); %>
    the problem is that the server tries to load the class from the package : org.apache.jsp.Car ! when putting car into an own package like my.Car then it works.. but how do i get it working without putting it into a separate package?!
    thx

    You could try packaging it in a jar, and placing the jar in WEB-INF/lib... I have no idea if that will help, but when you're debugging, you have to be willing to try anything.. :)

  • Accessing java class and methods within JSP

    Hi All,
    I am writing a JSP page, and need to instantiate an object of a certain class within my package, in my JSP page.
    How do I do that? Do i use the <%import = "Whatever.class" %>
    Any help would be greatly appreciated.
    Kal.

    Hi.. Thanks for ur reply.
    I am actually having a problem with the import statement. So the part where you have mypackage.Myclass, it is not working for me.
    I am using Sun Forte.. and the directory is myprojects/test/Classes/MyClass.java
    so how would the import statement look like?
    Thanks
    Kal.
    Using directive for import statements:
    <%@ page
    import="java.util.*,java.sql.*,mypackage.MyClass" %>
    Then use scriptlet:
    <%! MyClass c= new MyClass(); %>
    <%! private void method() {...} %>
    <%= c.getxxx() %>
    ...and so on

  • JSP Question

    How can I run a snippet of code upon a user request using JSP? It seems that whether the code is within <% %> or <%= %>, it is always run once the page is displayed. In javascript I am able to run a section of code in this fashion:
    <a href="javascript:someCode()"></a>
    Is there any way to do something similar using JSP?

    If you want to execute java code which is present in the same JSP upon some action of the user, then post the page to itself, for eg.
    if your jsp page is Test.jsp residing at address
    http:\\127.0.0.1:8080\test\Test.jsp then in ur JSP, in the html form tag specify the action as
    <form name="frmTest" method="post" action="Test.jsp">
    (Note: the host ip is not required if ur calling the same JSP)
    you could use the following eg.JSP name :BTLogin.jsp
    <%@ page autoFlush="true" errorPage="ErrorPage.jsp" %>
    <jsp:useBean class="LoginBean" id="loginBean" scope="page"/>
    <%
    // check the request out if this page was called by itself, if so then
    // request.getParameter will contain values, else it will be null
    userName = request.getParameter("txtUserName");
    password = request.getParameter("txtPassword");
    if (userName != null && password != null)
    retStatus = loginBean.login(userName,password);
    %>
    <Html>
    <Body background="beige">
    <form Action="BTLogin.jsp" Method="post" Name="frmLogin">
    <Table align="center">
    <tr>
    User Name :<input ID="txtUserName" Name="txtUserName" Type="text">
    </tr>
    <tr>
    Password :<input ID="txtPassword" Name="txtPassword" Type="password">
    </tr>
    <tr>
    <input ID="btnReset" Name="btnReset" Type="reset" Value="Reset">
    <input ID="btnLogin" Name="btnLogin" Type="submit" Value="Login">
    </tr>
    </table>
    </form>
    <center>
    </center>
    </body>
    </Html>

  • Abstract portal component and JSP question

    Can we use htmlb components in abstractportal components.
    I am using isolatedhtmlcontainer in abstractportal component and it is not compiling. It works fine with Dynpage component
    Also one more question can we just write a JSP to get the userid of the portal. I tried typecasting request object to IPortalComponentRequest , but iam not able to get the userid . Can anyone suggest anything . I want get the userid from the jsp and pass this userid to asp as query string
    Thanks
    LAK

    Yes you can create a JSPDynPage and define the component type as NativeJSP in portalapp.xml for e.g.
      <i>      <property name="ComponentType" value="jspnative"/>
            <property name="JSP" value="pagelet/YourJSP.jsp"/></i>
    The explicit object for IPortalComponentRequest is componentRequest in JSP. The other way to get componentRequest is
    IPortalComponentRequest       currentRequest       = (IPortalComponentRequest) pageContext.getAttribute(javax.servlet.jsp.PageContext.REQUEST );
    to get the user further just call currentRequest.getUser()

  • Using jsp variables within JSP tag

    I have a variable defined within a JSP:
    <%
    String cust_id = request.getParameter("cust_id");
    %>
    I want to use this variable as a parameter to a custom tag:
    <%@ taglib uri="/tlds/DBTags.tld" prefix="db" %>
    <db:MultiColumnSelect columns="c.id, c.po" name="ccar_id" table_name="ccar_headers c, ccar_rmas r" selectString="r.ccar_id = c.id AND c.cust_id = <%= cust_id %>"/>
    The selectString value that is passed to my tag is:
    r.ccar_id = c.id AND c.cust_id = <%= cust_id %>
    The <%= cust_id %> is not replaced by the actual variable value.
    How would I accomplish using this variable within my JSP tag?

    Your definition of the selectString attribute must indicate that it can accept runtime expressions.
    <%
    String cust_id = request.getParameter("cust_id");
    String selectString = new String("r.ccar_id = c.id AND c.cust_id = " + cust_id);
    %>
    <%@ taglib uri="/tlds/DBTags.tld" prefix="db" %>
    <db:MultiColumnSelect columns="c.id, c.po" name="ccar_id" table_name="ccar_headers c, ccar_rmas r"
    selectString="<%= selectString %>"/>

  • How to invoke a 6 parameter java class within jsp

    i have just begun to learned jsp and java recently, so have the question below:
    Situation:
    My boss asked me to do a project for doing online data mining.
    He requested the thing below:
    1. Write a webpage by jsp with some textfield or pull down meun to get the parameter for getting the opinion and the parameter needed for the java class.
    2. When the user click the buttom in the website, then the java class have to be invoked.
    Questions:
    1. ask i put the .java in the server, i can simply use cmd and type the following command:
    java -Xmx800M P05context 1 1 3 6 F01xyz.txt F10xyz.txt
    which F01xyz is the prepared text file for the java class to read and the F10xyz.txt is the output file generated by the P05context.class
    but i don't know how to invoke the P05context.class by jsp
    My boss have suggested me two ways to do this:
    a. write a java virtual class to execute the java program.
    but i don't know how to write.
    i think conceptualy will be like this :
    public class run_java
    public void run java(parameter1,parameter2....,parameter6)
    //run the cmd command
    //java -Xmx800M P05context 1 1 3 6 F01xyz.txt F10xyz.txt
    b. write a javabean in the jsp. and i have try to use this code(at the end of the message:
    but the tomcat server reply a internal error to me
    how cani do ?
    the jsp file-->
    <jsp:useBean id="test" scope="session" class ="P05context" />
    <html>
    <head></head>
    <body>
    <% test.P05context(1,1,3,6,F01xyz.txt,F10xyz.txt); %>
    </body>
    </html>

    I still don't see why the form (the origin of the request) has to be a JSP, As you say, it might be static but forms I've written have usually had some kind of menu framework arround them and other variables. Also if the input is invalid you usually want to re-present the form, with an error message and the fields pre-populated according to what the user put in before. That does require a JSP and you may as well use the same JSP for an empty, as for a rejected request.
    the response to the form should be handled by a servlet. Both is HTML, but the
    form is static, and the reply dynamic. Using the combination; a servlet to do the data processing and a JSP to format the results is more flexible in a number of ways. For example, suppose you find the need to present the data form in, say, Greek? You don't want the processing to be duplicated in English and Greek versions of the results JSP.
    Suppose the boss wants to turn a graphics designer loose on your HTML. Don't want him mucking about with your processing code do you.
    The servlet typically takes the function of controller in the model/view/controller paradigm.
    Code in a servlet is cleaner, better formatted and easier to access with a debugger.

  • Using Collections within JSP and beans

    Hi I have a bean setup that contains a collection (linkedList of objects)
    A servlet sets up all the information and forwards to a jsp page
    ResourceInformation resourceInfo = new ResourceInformation();
             resourceInfo.setResourceList(list);
             request.setAttribute("resourceInformation",resourceInfo);
             RequestDispatcher dispatcher = request.getRequestDispatcher(address);
             dispatcher.forward(request,response);My question is what is the prefered way of iterating through this collection from the jsp page
    as I havent been able to find any examples of JSP pages utilising collections
    Thanks a lot

    The JSTL (http://java.sun.com/products/jsp/jstl/) contains a <c:forEach> tag you can use to iterate collections - e.g:
    <c:forEach var="resource" items="${requestScope.resourceInformation.resourceList}">
      <tr>
        <td>${resource.name}</td>
      </tr>
    </c:forEach>

Maybe you are looking for

  • Problem: "Select a Range" doesn't work (Cannot mark data from MS Excel)

    Hi, I need Your help. I have some problem with connection with MS Excel. I can't use MS Excel range as data source. Please find short overview of this situation (video clip): [http://www.explorer-consulting.pl/XC-prob.swf|http://www.explorer-consulti

  • Best practice for ASA Active/Standby failover

    Hi, I have configured a pair of Cisco ASA in Active/ Standby mode (see attached). What can be done to allow traffic to go from R1 to R2 via ASA2 when ASA1 inside or outside interface is down? Currently this happens only when ASA1 is down (shutdown).

  • Material gropu changed.

    Hi, We had changed the old material group eg. from GP1 to GP2. Now i want to overwrite the transaction data in oDS with new Material group.For this I need to copy the OLD ODS(e.g ODS1) data to new ODS(e.g.ODS2), do the changes in the update rule of O

  • "iTunes has encountered a problem" after updating Podcasts

    I've been running iTunes happily since December 2009 on my Windows XP machine. I've allowed each update to be applied and have never had a problem with it. Suddenly today, I started getting an "iTunes has encountered a problem an needs to close" erro

  • 2900 FXO Port remains in off-hook after call

    Hello I have a 2900 router with FXO ports running Cisco IOS Software c2900-universalk9-mz.SPA.151-4.M5.bin . The problem is when the call is ended and we hung-up, port remains in off-hook and the line remains busy for long time.