Nicer method for inserting dynamic into a JSP

I have a site layout which has header.jsp, menu.jsp, content.jsp(s), footer.jsp.
Instead of having 10 various topic pages all of which including header,menu, and footer into them, I have opted for one JSP that loads the content.jsp based on a parameter in the URL e.g,
index.jsp?content=news
index.jsp?content=polls
index.jsp?content=products
So far I can do this by :
<jsp:include page="includes/header.jsp" />
<jsp:include page="includes/menu.jsp" />
<%
String content = request.getParameter("content");
String action = request.getParameter("action");
String id = request.getParameter("id");
if(content.equals("news"))
if(action == null)
%>
<jsp:include page="news/content.jsp" />
<%
else if(action != null)
%>
<jsp:include page="news/form.jsp" />
<%
if(content.equals("forums"))
if(action == null)
%>
<jsp:include page="forums/content.jsp" />
<%
else if(action.equals("edit"))
%>
<jsp:include page="forums/showtopic.jsp" />
<%
// other IF blocks here
%>
<%@ include file="includes/footer.jsp" %>
footer.jsp in constant so it is '<%@ include', the header and menu have content which can vary between views so they have '<jsp:include'.
Originally I thought I could have one single
<jsp:include page="<%=content%>/content.jsp" />
or find any means to use the content variable to feed it into the JSP:INCLUDE, but it doesn't seem to be possible.
Does anyone have any ideas for me?
Many thanks

Originally I thought I could have one single
<jsp:include page="<%=content%>/content.jsp" />
or find any means to use the content variable to fee
it into the JSP:INCLUDE, but it doesn't seem to be
possible.
Does anyone have any ideas for me?
Try:
<% String pageName = content + "/content.jsp";   %>
<jsp:include page="<%=pageName%>"/>or
<jsp:include page='<%=content + "/content.jsp"%>' />

Similar Messages

  • API for insert Lead into telesales

    How can Insert lead for customer using API in Telesales

    Hi,
    Currently, I believe there are no api's to populate the pa_transaction_control table.
    If this is a new implementation and you are converting the projects from your legacy system for the first time, you should be able to directly insert date into these tables. This table does not have many FK relationships. Mainly depending on the transaction control is set at the Project or the Task level, you can set the values for Project id /Task id.
    I would also suggest that you confirm with Oracle by creating a Tar that there is no API currently available.
    - Vasu -

  • Which trigger to use for insert data into db table in Forms

    Hi,
    My form is current having a database block with table reference. When enter data into form field and click on save button. Automatically the record is inserted into database table.
    I want to make this as manual insert. I changed the data block to a non-database. Where should i write the insert statement in order to insert data into table.
    Is it Key-commit trigger at form level?
    Please advise.
    Thanks,
    Yuvaraaj.

    Hi Yuvaraaj.
    Insert should happen when we click on the save which is inbuilt in the form. In this case where should i write the insert statement.Forms in built save commit's the form data where block is based on database not non database.
    @2nd reply
    Ypu are right. The reason i chnaged the database block to non-database is Currently i have a database block with form field canvas which insert only 1 record in to >table when we click on standard save button. The requirement was to add a field called CHANNEL which should have multiple values displayed. (i created this channel >field in a seperate datablock (non database) and used the same canvas.) When we insert data in all fields (single record) and channel we should be able to selected >multiple channel (say A,B and C) when we click on save then 3 records should be inserted in to the table which looping values for each channel. This was the actual >requirement and this is the reason why iam changing the block to non-database block.You are talking about two blocks.. 1. Master block and 2. Details block name channel
    You are inserting one record in master block then insert 3 record name A,B,C for that master record.
    Now you want master record should insert to each A,B,C record. Means
    'how are you' --master record
    and you want
    'A'- 'how are you'
    'B'- 'how are you'
    'C'- 'how are you'OR
    ?Ok. If you want master record save in database and then want to save non-database(channel) data into database USE Post-Insert trigger at block level and do the rest.
    Hope this helps...
    Hamid
    Mark correct/helpful to help others to get right answer(s).*
    Edited by: HamidHelal on Jan 26, 2013 1:20 AM

  • Query for inserting data into table and incrementing the PK.. pls help

    I have one table dd_prohibited_country. prohibit_country_key is the primary key column.
    I have to insert data into dd_prohibited_country based on records already present.
    The scenario I should follow is:
    For Level_id 'EA' and prohibited_level_id 'EA' I should retreive the
    max(prohibit_country_key) and starting from the maximum number again I have to insert them
    into dd_prohibited_country. While inserting I have to increment the prohibit_country_key and
    shall replace the values of level_id and prohibited_level_id.
    (If 'EA' occurs, I have to replace with 'EUR')
    For Instance,
    If there are 15 records in dd_prohibited_country with Level_id 'EA' and prohibited_level_id 'EA', then
    I have to insert these 15 records starting with prohibit_country_key 16 (Afetr 15 I should start inserting with number 16)
    I have written the following query for this:
    insert into dd_prohibited_country
    select     
         a.pkey,
         b.levelid,
         b.ieflag,
         b.plevelid
    from
         (select
              max(prohibit_country_key) pkey
         from
              dd_prohibited_country) a,
         (select
    prohibit_country_key pkey,
              replace(level_id,'EA','EUR') levelid,
              level_id_flg as ieflag,
              replace(prohibited_level_id,'EA','EUR') plevelid
         from
              dd_prohibited_country
         where
              level_id = 'EA' or prohibited_level_id = 'EA') b
    My problem here is, I am always getting a.pkey as 15, because I am not incrementing it.
    I tried incrementing it also, but I am unable to acheive it.
    Can anyone please hepl me in writing this query.
    Thanks in advance
    Regards
    Raghu

    Because you are not incrementing your pkey. Try like this.
    insert
       into dd_prohibited_country
    select a.pkey+b.pkey,
         b.levelid,
         b.ieflag,
         b.plevelid
       from (select     max(prohibit_country_key) pkey
            from dd_prohibited_country) a,
         (select     row_number() over (order by prohibit_country_key)  pkey,
              replace(level_id,'EA','EUR') levelid,
              level_id_flg as ieflag,
              replace(prohibited_level_id,'EA','EUR') plevelid
            from     dd_prohibited_country
           where level_id = 'EA' or prohibited_level_id = 'EA') bNote: If you are in multiple user environment you can get into trouble for incrementing your PKey like this.

  • Does adobe have alternatives for inserting photos into templates?

    I have just downloaded this software in the hope that I can use some template files. They are eps and elements 13 doesn't support it.
    In addition to this the only other thing that I wanted elements for was to remove backgrounds. I can't find a tutorial on that. The only one listed is for CC.
    The only use I have for the software is to insert photos into a sublimation template. Do Adobe have an alternative that can do this?

    Please review this and get back with issues that need additional clarification:
    How to import my images into templates for sublimation blanks [was: inserts]? [was: HELP]
    As for EPS files, Irfanview will open them, and then you can save them as JPEG files and open them in PSE.
    Irfanview is a terrific program, free: www.irfanview.com

  • Calling webservice in udf for inserting data into webservice

    Dear Experts,
          Please give me the drawbacks of using lookup function for inserting data. we are calling a webservice from the udf for inserting the data using a webservice.
    It is a file to jdbc usnig a soap lookup . we use this approach because we need to pass the response from webservice along with the error data to the jdbc.   is there any other way to do it without using bpm ?
        In the udf we are creating the xml structure for webservice and passing the parameters through arguments.
    is there a better approach for this ?
    Thanks,
    Aju

    Hi Aju,
    You can do it without BPM.
    Write UDF for Soap Lookup. Parse the response message from Webservice.  and map the required values to respective fields.
    See the weblog
    Webservice Calls From a User Defined Function.
    Negative point of this solution is that it will take some time to call Webservice and get response back from it.
    Kulwinder

  • Using model 1 Architecture for inserting row into DB...

    The question is on the design of a JSP using Model 1 architecture.
    I have a html form with 3 fields taking input from user. I have made a java bean with 3 instance varibales in the name of the field names and with getter() setter() methods too.
    I dont want to hardcode the database access in the JSP. How do i acheive modularity or make use of object orientation concepts in the JSP to open aconnection and save the record into a database.
    I dont want the conventional way of harcoding like registering DriverManager... Creating Statement opject and OPening Connection...... and with Statement object to call executeUpdate() method...
    These all should be encapsulated in class and methods so that my JSP looks simple......
    Java Gurus, How do i get going.........

    Untill now, I have motsly written java web applications merely showing information; there's no insert or update available. nevertheless, the design pattern MVC or Model-View-Controller can work just as good for display-only web apps as for the rest.
    You're right if you don't want to have the database connection inside your JSP's. So how do you have to deal with it. The letters MVC already tell a part of the story. You have 3 kinds of objects :
    - Model : the so-called Java Beans; these objects refer to the concepts known to the usezr of the web app, like Client, Product, Order, Orderline, Invoice, Payment
    - View : these are the JSP's
    - Controller : this is the heart of the web app; Java uses the servlets to be the controller.
    But there's another kind of object you will need, namely the DAO or Data Access Object. These objects define the contact with the database, contain the SQL-statements and make objects of the Model type.
    I'll give 2 examples. The first is the GeneralDao which you define just once. This GeneralDao contains the database driver you're using.
    /** Java class "GeneralDao.java" generated from Poseidon for UML.
    * Poseidon for UML is developed by Gentleware.
    * Generated with velocity template engine.
    package org.gertcuppens.dao;
    // import java.util.*;
    import java.util.ResourceBundle;
    import java.sql.*;
    /* import org.apache.log4j */
    import org.apache.log4j.Logger;
    public abstract class GeneralDao {
    // operations
    * de GeneralDao is de algemene klasse waar alle andere DAO's of Data Access
    * Objects van erven. Het is de bedoeling om in deze klasse ��nmaal de
    * getConnection te defini�ren
    * <p>
    * getConnection() connecteert met de databank afhankelijk van de JDBC-driver
    * die voorhanden is. Deze methode zorgt ervoor dat alle afgeleide DAO's van
    * dezelfde driver gebruik maken terwijl er toch maar op ��n plaats de naam
    * van de driver gedefinieerd is.
    * </p>
         protected Connection getConnection()
              throws java.sql.SQLException
         Connection dbconn = null;     
         ResourceBundle resBundle;
         Logger mopoLogger = Logger.getLogger("mopo.log");               
         mopoLogger.debug("start connectie databank " );      
              try
              Class.forName("com.mysql.jdbc.Driver").newInstance();
              resBundle = ResourceBundle.getBundle("gcoConfig");
              mopoLogger.debug("ophalen resourceBundle (gcoConfig) " );
              String dbConnectie = resBundle.getString("databaseconnection");
              mopoLogger.debug("lezen databaseconnection in resourceBundle " );
              //dbconn = DriverManager.getConnection("jdbc:mysql://localhost/gco");
              dbconn = DriverManager.getConnection(dbConnectie);
              mopoLogger.debug("maken connectie databank " );
              } catch (InstantiationException e)
                   System.out.println("GeneralDao - Fout bij getConnection - instantiation " );
                   mopoLogger.fatal("GeneralDao - Fout bij getConnection - instantiation " );
                   e.printStackTrace();
              } catch (IllegalAccessException e)
                   System.out.println("GeneralDao - Fout bij getConnection - illegal acces " );
                   mopoLogger.fatal("GeneralDao - Fout bij getConnection - illegal acces " );
                   e.printStackTrace();
              } catch (ClassNotFoundException e)
                   System.out.println("GeneralDao - Fout bij getConnection - class not found " );
                   mopoLogger.fatal("GeneralDao - Fout bij getConnection - class not found " );
                   e.printStackTrace();
              return dbconn;
    } // end GeneralDao
    Each object of the Model type should have a corresponding DAO. In my webapp I had 3 kinds of model objects, so I've defined 3 DAO's. All these DAO's are children of the GeneralDao. I'll give an example of this.
    package org.gertcuppens.dao;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import org.gertcuppens.general.Gebruiker;
    /* import org.apache.log4j */
    import org.apache.log4j.Logger;
    public class GebruikerDao extends GeneralDao {
    * Zoekt de gebruiker op aan de hand van de opgegeven naam en wachtwoord
    * @return Gebruiker
    * @param _naam
    * @param _wachtwoord
    public Gebruiker findGebruiker(String naam, String wachtwoord)
    throws SQLException
         Logger mopoLogger = Logger.getLogger("mopo.log");               
         mopoLogger.debug("start findGebruiker" );      
    StringBuffer zoekString = new StringBuffer();
    zoekString.append ("select * from gebruiker ");
    zoekString.append("where naam=? and wachtwoord=? ");
         Connection con = getConnection();
    PreparedStatement ps = con.prepareStatement(zoekString.toString());
    ps.setString(1,_naam);
    ps.setString(2,_wachtwoord);
    ResultSet rs = ps.executeQuery();
    if (rs.next() )
    Gebruiker gebruiker = new Gebruiker(rs);
    rs.close();
    ps.close();
    con.close();
    mopoLogger.debug("gebruiker gevonden " + gebruiker.getNaam());
    return gebruiker;      
    else {
                   ps.close();
                   con.close();
                   mopoLogger.debug("geen gebruiker gevonden");
                   return null;
    } // end findGebruiker
    } // end GebruikerDao
    Want to know more about this ? Just give me a sign.

  • Better way for inserting column into array?

    I have to insert a 2-D array(20x10) into the end (column) of a bigger 2-D array(1000x10). I am seeing two ways to do that:
    1. Insert smaller 2D array at the end of bigger array.
    2. Insert the bigger array at the 0th column of smaller array.
    Which one would be more efficient? Will there be any performance difference?
    Or any other better way to do this?
    The second one looks simpler but I think it would require a bigger copying of memory.

    Both methods use a buffer allocation, so they might be very similar. Since we don't know what the compiler is doing, you could also try this:
    I am assumung that you only need to append once and not append more and more columns as the program progresses. Is this correct? In any case, you should consider operating on the transposed version, because it is always easier to append rows instead of columns (rows are adjacent in memory, while appending columns require more data shuffling under the hood
    In any case, you should simply wire up the alternatives and do a proper benchmark if you are planning to use this on much larger arrays in the future, for example. Can you give us some context how you are planning to use this?
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    AppendColumns.png ‏3 KB

  • How to use record type for inserting data into a table

    I've read through the web the following tip:
    "When working with a large number of columns, using variables of type RECORD is a better approach. With this approach, you do not have to list anything in the INSERT statement, because you are inserting a variable into the table that is defined as a row from the same table."
    I usually define a variable as
    r_mytable     mytable%ROWTYPE;
    and inside my procedure I'll set the fields I need as
    r_mytable.field1 := 1;
    r_mytable.field3 := 7;
    and then I perform the insert as
    insert into mytable
    (field1,
    field3)
    values
    (r_mytable.field1,
    r_mytable.field3);
    According to the tip I've copied above, how can I use the TYPE RECORD of pl/sql for achieving the same result but perhaps in a smarter way?
    Thanks in advance!

    Hi,
    Are you looking for this?
    SQL> create table table1 (id number, descr varchar2(30));
    Table created
    SQL>
    SQL> DECLARE
      2   my_rec table1%rowtype;
      3  BEGIN
      4   my_rec.id := 1;
      5   my_rec.descr := 'TEST';
      6   insert into table1 values my_rec;
      7  END;
      8  /
    PL/SQL procedure successfully completed
    SQL> select * from table1;
       ID DESCR
        1 TESTWorks with UPDATE too :
    SQL> DECLARE
      2   my_rec table1%rowtype;
      3  BEGIN
      4   my_rec.id := 2;
      5   my_rec.descr := 'TEST2';
      6   update table1 set row = my_rec where id = 1;
      7  END;
      8  /
    PL/SQL procedure successfully completed
    SQL> select * from table1;
       ID DESCR
        2 TEST2

  • Need Logic for Inserting data into table from another table

    Hi,
    Could you please give me some logic on below:
    TABLE_A has columns A,B,C,D
    What i did
    ==========
    Created new table
    TABLE_1_A with columns A1,A2,B1,B2,B3
    Requirement
    ===========
    I should populate columns A1,A2 (table TABLE_1_A) with the data from column A (table TABLE_A)
    & simillarly populate columns B1,B2 with the data from B.
    the data is huge in the table_a.
    Database: 10g
    Thanks.

    Hi,
    Here's one way:
    INSERT INTO  table_1_a
            (a1, a2, b1, b2)
    SELECT      a,  a,  b,  b
    FROM      table_a
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    If you're asking about a DML statement, such as INSERT, the sample data will be the contents of the table before the DML, and the results will be state of the changed table(s) when everything is finished.
    Explain, using specific examples, how you get those results from that data.
    See the forum FAQ {message:id=9360002}

  • Createa a  method for creating dynamic queries

    Hi,
    I am trying to create a public method in a class to generate Dynamic SQL Queries.The method has 4 parameters :
    WHERESTRING TYPE STRING
    FROMTABLE TYPE STRING
    SELECTFIELDS TYPE STRING
    INTOTABLE TYPE ANY TABLE
    the process is :
    SELECT (selectfields) FROM (fromtable) INTO <INTOTABLE> WHERE (wherestring).
    However I get error in the INTOTABLE, it does not recognize the parameter. What am I doing wrong ?

    Resolved myself!

  • Class method for XI data into R/3????

    Hi Experts,
    I have a very big problem..please help me!!!!
    We need to create a program that will call data from XI interface and populate the internal table in R/3?
    Can any1 of u give me the steps to go forward with it?
    I read some documents and found that we need to use Class METHOD.. but I am new to OOPS and dont know anything in it.
    Its about server proxies I guess!!!
    I need to finish this in 1 day...
    Please help.. answers will be rewarded with points...

    Hi, Thanks for the reply. I cannot use IDOC.
    I have data in XI interface in form of XML data and i want to populate internal table in R/3 with this XML data(From XI).
    If anybody can give me the steps to do the same, it will be very helpful.
    my mail id is [email protected]
    please try to send me the steps with an example...

  • QUERY FOR INSERT INTO  SQL TABLE

    Hi all,
    i want to insert some records into SQL table but not SAP database table. This table is only present in SQL database &
    not present in SAP database.
      i want to write a program in SAP to update the SQL table(not present in SAP database). is it possible?
       if yes, plz give me the query for inserting records into SQL table.
    Regards

    Hello,
    working on the same issue:
    Try this:
    DATA : Begin Of XY Occurs 1000,
            id(15)    TYPE C,
            Name(50)  TYPE C,
            ArtNr(50) TYPE C,
            lieferant TYPE I,
         End Of XY.
    Fill this internal Table with the SAP-Table
    START Connection to your Database
      EXEC SQL.
          Connect TO 'TEST_FH'
      ENDEXEC.
      IF SY-SUBRC EQ 0.
        EXEC SQL.
        Set Connection 'TEST_FH'     " <-- this is defines with TCode dbco
        ENDEXEC.
        IF SY-SUBRC EQ 0.
        Else.
          " OUT_Msg = '... won't connect'.
          Exit.
        EndIf.  " Else IF SY-SUBRC EQ 0
      Else.
        " OUT_Msg =  'Error at Set Connection Test_FH'.
        Exit.
      EndIf.  " IF SY-SUBRC EQ 0
    ENDE  Connection to your Database
    START Insert your table XY to an external database
        Loop AT XY.
          Try.
           EXEC SQL.
               INSERT INTO stoff
               (id, name , artnr, lieferant)
               VALUES
               ( :XY-ID,  :XY-Name, :XY-ArtNr, :XY-Lieferant )
           ENDEXEC.
           COMMIT WORK AND WAIT.     " <=== Maybe VERY important
          CATCH cx_sy_native_sql_error INTO exc_ref.
              error_text = exc_ref->get_text( ).
              Concatenate 'Table-INSERT: ' error_text Into error_text.
              MESSAGE error_text TYPE 'I'.
          ENDTRY.
        ENDLoop.     " Loop AT XY     
    END   Insert your table XY to an external database
    START: Clear Connection
        EXEC SQL.
          DISCONNECT 'TEST_FH'
        ENDEXEC.
    END : Clear Connection
    Hope it works
    Best wishes
    Frank

  • Best method for dynamically populating PDF on the web?

    Hi there,
    I'm trying to find a web-based solution to populate text within an existing PDF with a person's name (using a name variable within the PDF body copy in several spots).  I know that LiveCycle Designer is the best method for creating dynamic PDF's but since I'm on a Mac, LiveCycle Designer wasn't packaged with my CS5 Suite / Acrobat 9 and I'm not eager to run windows in parallel and pay for acrobat pro a second time just to have it on windows for the LiveCycle functionality...CS5 wasn't cheap ha. 
    So I'm trying to find out if there are alternative ways to achieve this without going down that road.  I don't mind writing PHP or using some other programming language to set it up online, but I just seem to be finding many different methods coming up and cannot find the most straightforward solution.
    Any help is greatly appreciated!

    LiveCycle Designer won't do what you want. It requires server software: LiveCycle Forms will do the trick.
    You can find information on it here: http://www.adobe.com/products/livecycle/forms/

  • Adding Form for insert into Ext Js Layout

    Hi all,
    How to adding form for insert record into EMP table
    +[http://apex.oracle.com/pls/apex/f?p=43040:7|INSERT EMP]+
    into Ext JS layout with one Array Grid report from EMP ?
    +[http://apex.oracle.com/pls/apex/f?p=43040:5|ExtJS layout EMP report]+
    (this is extend threat from
    Re: ExtJS report with JsonStore -examples? apex and extjs grid table]
    implements by munky)
    regards,
    Gordan
    Edited by: useruseruser on Aug 3, 2010 9:17 AM

    Hi Gordan
    Just for information, the link syntax doesn't work on the forum anymore, just paste the link in with no tags or brackets and it will be 'clickable'.
    Exactly what are you trying to achieve here?
    Have you had a look at these sites which may be of some use to you...
    http://oracleinsights.blogspot.com/ - Mark Lancaster
    http://application-express-blog.e-dba.com/ - e-DBA (Matt Nolan)
    http://apex-at-work.blogspot.com/ - Tobias Arnhold
    Cheers
    Ben

Maybe you are looking for

  • Key figure in a series

    Hi SDN, Our customer pointed out that on a certain metric, the key figure needs to a additive series, rather than an individual value. So except for the 1st fiscal quarter every other qtr is sum of itself and the previous qtr - within a single year.

  • How to create purchase order using VA01 for BAPI?

    how to create purchase order using VA01 for BAPI?

  • Defining default value for financial reports display in the workspace (9.3)

    Hi I need to change the default value for financial reports workspace preview mode, for every workspace user. It is actually set on html, and I would like to have pdf instead. This option can be changed when logged on the workspace, in file->preferen

  • Problem while Importing Transport Request

    Hi Friends We are trying to import a transport request, while importing abap dictionary objects, in the log it is showing not imported. we have tried the same request in other system, but it works fine there. Can you please anyone explain what may be

  • Transfer Data from PalmOne Zire31 to the new Palm Pre?

    Hi all, I've done some research to see how I can transfer the calendar and the contacts on my PalmOne Zire31 to my new Palm Pre and find PocketCopy from Chapuro to help do that without loosing the info on the PalmZire 31. I was wondering if anybody k