Using JSPs as a generic text template language

I am about to start a project with a lot of code generation. I intend to use templates to minimise the amount of println's in my code and to ease maintenance.
I am looking at this style of code:
For each file to be generated:
1) Set up a Javabean with the relevant data
2) Call a template which will substitute data from the Javabean
3) Output the stream from that template to a file
I have looked at Velocity which is easy to call from Java without requiring a URL request. However, I would like to use the JSP syntax as this provides a standard way for me to do my templating (I already use JSPs for web page generation).
Does anyone know how I can use JSP s in this way, i.e. calling them from a command line. I have tried using jspexcutor but have had severe diffiulties when using with Tomcat 3.3.
Thanks in advance
Martin

I'm doing this now to generate Data Access Objects. I wrote the template as a JSP file, and I'm opening up an URL connection and writing the results to a Java source file. It works, but it's not pretty. I'm also looking for a nice way to do templating but haven't found anything so far. If you find something please let me know.
Mark

Similar Messages

  • How to create a PDF with substituted key-value and table-values using a template language

    I have about 50 key-values and 10 table-values that I want to substitute into a formatted report template (language can be anything standard, would create a small number of these templates) and then use an Adobe tool to substitute the values into the template and produce a PDF. Preferably the template language would permit some basic conditional logic (if <key #> has value <value> then <show key label here> and <key value here> in close spatial proximity on the form) and permit embedding of a static graphic logo, text with fonts/styles, etc. to produce a polished report but also handle pagination (e.g. enable page breaks or numbering) to be handled automatically.
    What is a recommended template language and product to accomplish this?

    Are you thinking of something like a blank form that you can enter information into, save, and send to another user? If so, what you want is possible. If you want more information, post again and include more details about how you want to use it and how the recipient will use it.

  • Generic Text DataSource using FM

    Hi All,
    I need to create a generic text DataSource in R/3 using a FM.
    I tried to create a text DS using a FM based on FM RSAX_BIW_GET_DATA_SIMPLE (as template).
    I tested it in R/3 using RSA3 and everything worked as expected, but after replicating it in BW and assigning it to an InfoSource I detected a problem.
    What happens is that BW receives all existing records with all fields but the text field filled! I couldn't figure out why.
    I recon there's also another FM template which seems to be specific for text extraction (RSAX_BIW_GET_TEXTS), but this FM happens to be incompatible with a Generic DataSource, in other words FM RSAX_BIW_GET_TEXTS does not have the expected interface parameters.
    Has anyone ever successfully created a Generic text DataSource using a FM? I've looked around the forums and could not find any example.
    Thanks for the attention and for any help.
    Ricardo Calaça Nunes

    Hi Ajay,
    First of all, thanks for your reply. Answering your question: yes, that's exactly what happens.
    Let me explain my problem a little bit further. I've created a custom characteristic in BW, this InfoObject was created with texts option checked. I want to load texts for this InfoObject in BW using an algorithm that reads data in R/3 hence my need for a generic text DataSource using FM.
    FM RSAX_BIW_GET_TEXTS which is also a template seems to be specific for text extraction, but a generic DS is not accepting a extraction FM based on it because its parameter interface is different from FM RSAX_BIW_GET_DATA_SIMPLE.
    The latter is good for master data extraction, I've successfully used it in the past, but as mentioned in my previous post BW seems not to accept text fields in a extraction structure filled by a FM based on RSAX_BIW_GET_DATA_SIMPLE whether this FM is in a generic master data DS or else in a generic text DS.
    Can you imagine a possible solution?

  • Printing Crystal report using Generic Text output - formating lost

    Hi. I have an accounting system using Crystal to generate it's business forms, in particular invoicing as reports. Recently we have installed new printing system that needs generic text to capture and create the business forms (invoices) into a graphic and text. When Crystal sends data to Generic Text Printer, you can view it ok as a preview but it moves text around , bunches it up and formatting is never the same for two documents. I need resolution as the printing software needs fixed text in a specific location within the data file.  Is there a way in Crystal to format fields so they dont move the data and bunch it up. The business forms written in Crystal have sub reports that are supressed if no data is to be printed, but finding text is moving and hard to capture a fixed location in text file. Any suggestions would be appreciated.

    Hello,
    Thank you for your responses.
    Yes, I'm using a bundled version that came with VS 2005.
    I'd love to download this update, but I cannot get there! I don't have an login and password for this site, and I don't know how to get them.
    This is all I'd found about this issue in this thread:
    http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=844
    "I opened an incident with Business Objects.  They said there is not a way to do what we want to do with the Crystal Reports for .NET assemblies.  They are going to implement a way to create a postscript file and include it in Service Pack 3 of Crystal XI Release 2.  They would not say how the postscript will be created (ie, ExportToDisk or any other method), only that they would include it in CRXI Release 2 SP3 which they intend to release sometime this coming winter. "
    "Just an update...this has been fixed in Crystal XI Release 2 Service Pack 3.
    I just finished testing, and it now allows you to print to a file without prompting the user.  We are now able to create a postscript file."
    Thanks,
    Peter
    Edited by: Peter Afonin on Jul 16, 2008 11:52 AM

  • Live text template render issue when using Media Encoder?

    I'm running into flash frames with Media Encoder exports of Premiere sequences using the live text templates.
    Unfortunately, AME doesn't flag it as an error, so the render completes without any issues in the render log and the only way to find it is to watch the rendered file.
    I have tried different combinations of having After Effects open or closed, with the live text template comp open or closed; I can't consistently reproduce the problem with any certainty and so am having trouble pinpointing the source.
    My only hypotheses so far are that:
    The glitches seem to be happening in the dynamic link between AME and PP, not AE and PP. The live text will pop back to the duplicated comp's text for one frame. Video playing simultaneously doesn't pop.
    In other words, the AE text template said: "name here". In PP it was edited to say "John Doe", then that comp was duplicated and edited to say "Bob Smith". Everything looks fine in PP. There are no keys on the source text in AE (I have noticed that if there are keys on the source text in AE, the text will pop back to the original AE text at that key in PP).
    When rendered out of AME, halfway through Bob Smith's title, it will read "John Doe" for a single frame, then pop back to being Bob.
    I've only had this happen so far with AME renders. The renders out of PP haven't given me any issues so far.
    It might happen more frequently on longer segments? If a title is up for 45 sec instead of 10 sec, it may be more likely to pop.
    The issue seems to occur more often in batch renders out of AME (happened to 3 of 5 files rendered in a batch, AME 2014.1) and/or with unrelated AE comps open (on a single render from AME 2014.2)
    Again, it doesn't happen every time or to the same title, or in the same spot. Files are being rendered to ProRes 422 HQ. Unchecked "Use Previews" in AME.
    Would be nice to get to the bottom of what's happening so I can recommend something to the editors when I hand off these live text templates to them.
    I realize that the live text is a new feature as of 2014.1, but haven't found anyone else talking about this. Would love if this was a very simple fix that I'm missing.
    I was able to reproduce the error on 2 different machines, with similar specs:
    Premiere CC 2014.1 and 2014.2
    Media Encoder CC 2014.1 and 2014.2
    Mac tower 2010
    2x 6-core Intel Xeon
    RAM: 64 GB
    Graphics: ATI Radeon HD 5770 and NVidia Quadro K5000 (or K4000)
    OS: 10.8.5 Mountain Lion

    I'm running into flash frames with Media Encoder exports of Premiere sequences using the live text templates.
    Unfortunately, AME doesn't flag it as an error, so the render completes without any issues in the render log and the only way to find it is to watch the rendered file.
    I have tried different combinations of having After Effects open or closed, with the live text template comp open or closed; I can't consistently reproduce the problem with any certainty and so am having trouble pinpointing the source.
    My only hypotheses so far are that:
    The glitches seem to be happening in the dynamic link between AME and PP, not AE and PP. The live text will pop back to the duplicated comp's text for one frame. Video playing simultaneously doesn't pop.
    In other words, the AE text template said: "name here". In PP it was edited to say "John Doe", then that comp was duplicated and edited to say "Bob Smith". Everything looks fine in PP. There are no keys on the source text in AE (I have noticed that if there are keys on the source text in AE, the text will pop back to the original AE text at that key in PP).
    When rendered out of AME, halfway through Bob Smith's title, it will read "John Doe" for a single frame, then pop back to being Bob.
    I've only had this happen so far with AME renders. The renders out of PP haven't given me any issues so far.
    It might happen more frequently on longer segments? If a title is up for 45 sec instead of 10 sec, it may be more likely to pop.
    The issue seems to occur more often in batch renders out of AME (happened to 3 of 5 files rendered in a batch, AME 2014.1) and/or with unrelated AE comps open (on a single render from AME 2014.2)
    Again, it doesn't happen every time or to the same title, or in the same spot. Files are being rendered to ProRes 422 HQ. Unchecked "Use Previews" in AME.
    Would be nice to get to the bottom of what's happening so I can recommend something to the editors when I hand off these live text templates to them.
    I realize that the live text is a new feature as of 2014.1, but haven't found anyone else talking about this. Would love if this was a very simple fix that I'm missing.
    I was able to reproduce the error on 2 different machines, with similar specs:
    Premiere CC 2014.1 and 2014.2
    Media Encoder CC 2014.1 and 2014.2
    Mac tower 2010
    2x 6-core Intel Xeon
    RAM: 64 GB
    Graphics: ATI Radeon HD 5770 and NVidia Quadro K5000 (or K4000)
    OS: 10.8.5 Mountain Lion

  • How to use jsp:scriptlet in site template

    hi all,
    I want to use <jsp:scriptlet> in site template, but jdev showed me an error msg when I put <jsp:scriptlet> in site template:
    scriptlet can not work properly with OJSP, I checked the forums, one possible solution is to encapsulate java code in jsp taglib, but I dislike this solution.
    Is there a way to disable OJSP? or any solution to use java code in site template?
    Best regards

    I believe the official word is if you are trying to use java code in a scriptlet in your site template then you are doing something wrong.
    The goal is to keep java code separate from the template and pages. Any logic should go to your supporting serviece objects and all of your front-end work should be accomplished using available or custom tags.
    Can you describe what you are trying to accomplish with this java code in your template?

  • Using JSP Get User's Default Language

    Hi!
    I have to get the User's Default language using JSP that the client is accessing website and u want to rederict him automatically to his default language which he is using. Like in google aur other websites.
    If it is also possible in Javascript then it is also acceptable for me.

    this can only be done if the request has the Accept-Language header set. You can read this using either request.getHeader("Accept-Language") or request.getHeaders("Accept-Language") for an enumeration of all the languages that the user will accept. Look at this page for details on the Accept-Language header: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html Note that the user agent (browser) does not have to provide this information (my Netscape browser does not, and I always get English from Google. My IE browser does, so I will get German if my default lang is set for German).

  • Shell program and XML Publisher E-Text Template

    Hi All,
    We have a customer submitting an rdf report through Shell script using the command line submission ar60run. This is being done in 11i.
    This rdf handles the File transmission with certain codes for the third party(same as E-Text templates in R12).
    Now, With BI Publisher can I use the Standalone CP of E-Text templates instead of Shell host program to submit the request.
    or Should I initiate the BI Publisher E-Text concurrent program through Shell Host Language.
    The Host program does not deal with any OS specific code.(Attached the Host program code for ref..,)
    Will there be any problem if I do not use the Host program to submit the BI Publisher E-Text Program.
    Code
    #!/usr/bin/ksh
    # $Header: ILSHINTF_HOST.prog 16/10/05 $
    # Last Update: 09/11/05 by Vadim Pasmanik
    # +=======================================================================+
    # Copyright (c) 2001 Oracle
    # All rights reserved.
    # +=======================================================================+
    #set -x
    OS_USER=$1
    AP_USER_ID=$2
    AP_USER=$3
    REQ_ID=$4
    P_LEVEL=$5
    P_SUPPLIER_TYPE=$6
    P_INACTIVE=$7
    P_SITE_USER_PAY=$8
    export NLS_LANG=American_America.IW8MSWIN1255
    unset XENVIRONMENT
    unset REPORTS60_PRINTER_CODE_BEFORE
    unset REPORTS60_PRINTER_CODE_AFTER
    #export TK_PRINTER=loc_printer
    #export REPORTS60_NO_DUMMY_PRINTER=false
    #TK_PRINT_STATUS="echo %n is valid"
    #export TK_PRINT_STATUS
    #env
    ar60run USERID=$OS_USER \
    P_CONC_REQUEST_ID=$REQ_ID \
    BATCH=YES \
    REPORT=$IL_LOC_TOP/reports/US/ILSHINTF \
    DESTYPE=FILE \
    MODE=CHARACTER \
    DESNAME=$APPLCSF/$APPLOUT/o$REQ_ID.out \
    DESFORMAT=$FND_TOP/reports/IL_DTSF \
    P_LEVEL="$P_LEVEL" \
    P_SUPPLIER_TYPE="$P_SUPPLIER_TYPE" \
    P_INACTIVE="$P_INACTIVE" \
    P_PAY_SITE="$P_SITE_USER_PAY"
    Thanks,
    Kiran.

    Hello Gurus,
    Just posting again... haven't received any reply...
    Request you to help me out.
    Thanks!

  • How to create generic text datasource to load text data?

    met issue in generic master data load
    Hi,
    please see above link for detail infomation regarding the attribute data load. now the language and description column of the infoobject s_saled is empty. i need to create a generic text datasource to load data from R3 to BW. the table which i use to extract attribute data is VBAK, but i don't find any filed relate to language and description.
    met issue in generic master data load
    can anyone tell me how to load the text data?
    thanks very much.
    Eileen

    hi eileen,
    go to transactio rso2  in your source system ie r/3.
    there u have three three fields for transaction data
                                                    attributes.
                                                     text.
    choose text and proceed as u did for trancsaction data load.
    thank u,
    reward if helpful.

  • Using java to call a text file

    I am new to java and was wondering if there is a way of using java to call a text file on my server and use it to create a webpage using a template. Namely to click a link to a poem, and have the java automatically create a page from a text file of the poetry. I need to know if this is even possible, what I would need to look into, (IE: which software or applet to look for), and if there are any sites that anyone knows about that I could learn how to do this. currently I am having to create a page for every poem posted on my site, which takes a great deal of time, and I would like to speed the process up a bit if it is possible. Any suggestions would be greatly appreciated.

    Why a text file? I don't think it is a best practice of doing that. Just use a database, keep your poem collections there, and set up a jsp page that seek the database, and then display it on another jsp page. I guess you can find similar application in the sample projects provided by JSC.

  • Problem using jsp:forward in java script

    hi,
    when I use jsp forward tag inside java script i'm getting a problem that
    when the jsp is invoked it is getting forwarded to the page specified in the forward tag, without checking the if conditions. Following code may give you a better idea.
    <html>
    <script>
    function test()
    if(document.f.htemp.value=="true")
    alert("jus");
    else
    var s=document.f.htemp.value;
    alert(s);
    <jsp:forward page="success.jsp" />
    </script>
    <body>
    <form name="f" method=post>
    <input type=text name=htemp value="true">
    <input type=button onclick="test()">
    </form>
    </body>
    </html>
    please help me,thanks inadvance
    regards
    chandu

    What pgeuens means is that you can't mix javascript and jsp/java code in this way.
    ALL of the jsp/java code gets executed at the server end.
    This produces an HTML page (with embedded javascript) which gets sent to the client.
    The client then runs javascript code in response to events (onLoad, onClick, onChange etc etc)
    So in this case, the jsp:forward will always be executed, because as far as the server is concerned, the javascript is just template text.
    If you WANT to do a conditional forwarding on the server side you do it in java ie (horribly using scriptlet)
    <%
    if (testCondition){
    %>
      <jsp:forward>
    %<
    %>Or if you want to test what the client has entered client side, all you can do is submit the form, or navigate to a URL
    <script>
    function test()
    if(document.f.htemp.value=="true")
    alert("jus");
    else
    var s=document.f.htemp.value;
    alert(s);
    document.f1.action="success.jsp";
    document.f.submit();
    </script>You cannot run JSP code based on your javascript code.
    Java. Javascript. Not the same thing.
    Hope this helps,
    evnafets

  • Text/expression-language-based paradigma continues?

    i've been working with jsp and struts for a while. the most significant drawback of jsp, custom tags/jstl and struts is its "runtime" binding caused by the heavy use of string-attributes and interpreted expressions.
    it makes the coding itself harder (loss of compiler support and strong typing), it increases the amount of testing (automated tests, regression tests) extremely, it makes jsp-apps very hard to mantain, it is error-prone when changed or refactored, it is slower in execution and last but not james requires extra developement tools (such as struts-editors) to effectively maintain the applications.
    but i like the paradigma of a web application that keeps a view state, handles "events" etc.
    the only thing i can't understand is why jsf builds on the error-prone jsp/custom tag paradigma instead of compiled server side ui components. it obviuosly still tries to follow the myth, that web-designers and application developers can share their source (i.e. js-pages) by using tags. imo this is a degeneration of the good idea to leverage html by some custom tags. these tags empower designers to make their pages dynamic. (enterprise) software developement ist very different: complex use cases, business logic and often ui-"logic", integration issues etc...
    the life cycle of a jsp with custom tags is weird (even more in struts):
    - objects (variables in scriptlets) already existing in the scope of the jsp-execute-method are wrapped into attributes of page, request or application scope.
    - tags are defined using string-based attributs, such as <html:write name="pinky" property="brain" />
    - the implementation of the tag tries to look up the object in any of the scopes, starting with page scope
    - if the object exists, it tries to read/set its property via reflection
    so you lose strong typing, compile time checks and performance.
    there are several frameworks that do not build upon jsp and tags but put in an extra layer. this layer is similar to a rich client "form" and renders the output into html or any other format.
    so i'm not preferring any framework, just looking around and curious why this architecture has been chosen for jsf.
    thanks
    tom

    the most significant drawback of jsp, custom tags/jstl and struts is its "runtime" binding
    caused by the heavy use of string-attributes and interpreted expressions.I second this heartily.
    but i like the paradigma of a web application that keeps a view state, handles "events" etc.
    the only thing i can't understand is why jsf builds on the error-prone jsp/custom tag
    paradigma instead of compiled server side ui components. The JSF - JSP connection is a major problem. More and more developers are starting to express reservations about it, because the two technologies don't play well together. But I think you've hit on an even deeper fundamental flaw in the equation -- the evils of runtime binding. The heavy JSF/JSP reliance on runtime evaluation is a reliability nightmare. Developers choose Java, in part, because of the robustness provided by compile-time checking. We give that up when it comes to JSF/JSP or Struts web applications, and that's an unacceptable state of affairs.
    Winer says that "JSF has taken a major step in the right direction with the <managed-bean> and <referenced-bean> configuration elements. These give some hope for development tools to finally provide real code insight (and even error reporting) for EL expressions, because they define both what keys are used in the expression language and what types of objects may be at those keys." However, this will help with only the simplest EL expressions. As soon as an EL expression reaches into nested properties and maps that aren't defined in the config file, we're back to runtime binding and error reporting. The addition of generics to the language with 1.5 might have made it possible to introduce strong EL type checking at page compile time, but Sun's short-sighted type-erasure implementation of generics rules this out permanently.
    Look at what Microsoft is doing with ASP.NET. It's not perfect, but the fundamental technology is based on compiled server side ui components. There are places in that framework where you can write expressions aren't evaluated until runtime, but it's certainly not the fundamental basis of the model as it is with JSF/JSP. And the .NET implementation of generics may make it possible to have these dynamic expressions type-checked at page compile time in a future implementation of .NET.
    I keep reading comments from the JSF proponents who say things to the effect of "yes, we know JSP doesn't play well with JSF, but JSF allows you to plug in a different rendering technology." Well, we need one, and we need it urgently. ASP.NET has been out for two years now, and was far more polished and useable at its release than JSF is now after a very long development cycle.
    Rightly or wrongly, people will judge JSF on the merits of the reference implementation. And I fear that a lot of developers are going to throw up their hands after a taste of the JSF/JSP world and move to .NET.
    Stephen Schaub

  • Using JSP to write data to MySql database

    Please help. I am trying to develop a website where a user registers by filling details required onto a page this data is then posted onto another page and displayed to user the user can the store this data into the database if they are satisfied with it. The problem is although this data is displayed on the next JSP page when I click on save the data is not written to my database.
    Code below the problem is with datasave.jsp
    Register.jsp:
    <html>
    <body bgcolor="#d0d0d0">
    <style type ="text/css">
    @import "style.css"; </style>
    <head>
    <script src="form_functions.js" type="text/javascript"></script>
    <script type="text/javascript">
    function validateForm()
         errorMessage = "The following field(s) require your attention:";
         hasErrors = false;
         newline = "\n - ";
         if( isInvalidEmail( form1.email.value ) )
              errorMessage += newline + "Email :: must contain a valid email address";
              hasErrors = true;
         if( isEmpty( form1.Firstname.value ) )
              errorMessage += newline + "Firstname :: must not be empty";
              hasErrors = true;
    if( isEmpty( form1.Lastname.value ) )
              errorMessage += newline + "Lastname :: must not be empty";
              hasErrors = true;
         if( isNotInteger( form1.phone.value ) )
              errorMessage += newline + "Phone :: must consist of numbers";
              hasErrors = true;
    if( isEmpty( form1.Address.value ) )
              errorMessage += newline + "Address :: must not be empty";
              hasErrors = true;
         if( isEmpty( form1.City.value ) )
              errorMessage += newline + "City :: must not be empty";
              hasErrors = true;
         if (!document.form1.accept[1].checked)
         errorMessage += newline + "Please accept condition to continue";
              hasErrors = true;
         if( hasErrors )
              alert( errorMessage );
              return false;
         else
              return true;
    </script>
    </head>
    <body>
    <p>
    <body>
    <script src="dateLastUpdated.js"
              type="text/javascript">
    </script>
    <p><h1>REGISTER YOUR DETAILS FOR YOUR BUYANDSELL ACCOUNT</h1></p>
    <!-- ************* start of form **************** -->
    <form
         name="form1"
         method="POST"
         action="datasave.jsp"
         onSubmit="return validateForm();"
         >
    <p>
         Email:
         <input type="text" name="email"/>
         </p>
    <p>
         Password:
         <input type="password" name="Password"/>
         </p>
    <p>
         Firstname:
         <input type="text" name="Firstname"/>
         </p>
    <p>
    LastName:
         <input type="text" name="Lastname"/>
         </p>
    <p>
    Phone:
         <input type="text" name="phone"/>
         </p>
    <p>
    Address:
         <input type="text" name="Address"/>
         </p>
    <p>
    City:
         <input type="text" name="City"/>
         </p>
    <p>
         Country:
         <select name="country">
              <option value="Eire">Republic of Ireland </option>
              <option value="Northern Ireland">Northern Ireland </option>
         </select>
         </p>
    <p>
    Terms and Conditions:
    If you accept the Terms and Conditions - please click on "I accept" at the end of this
    document.
    1. GENERAL
    This website is owned and operated by B&S Limited, trading as BuyandSell ("BuyandSell")
    whose head office is at BuyandSell House, Argyle Square, Donnybrook, Dublin 4. For the
    purpose of these terms and conditions "we", "our" and "us" refers to BuyandSell.
    <input type=radio checked name="accept" value="0"> I do not accept<br>
    <input type=radio name="accept" value="1">I have read and I accept the Terms and
    Conditions
    </P>
    <p>
              <input type="submit" value="Contact Details"/>
         </p>
    </form>
    <!-- ************* end of form **************** -->
    <centre>
    <script language="JavaScript1.3">
         // run script
         dateLastUpdated();
    </script>
    </body> </html>
    datasave.jsp:
    <html>
    <style type ="text/css">
    @import "style.css"; </style>
    <HEAD>
    </script>
    </HEAD>
    <p><h1>CREATE YOUR BUYANDSELL USER ACCOUNT</h1></p>
    </P class= "links">
    <body>
    <%-- Set the scripting language to Java and --%>
    <%-- Import the java.sql package --%>
    <%@ page language="java" import="java.sql.*"%>
    <%-- -------- Open Connection Code -------- --%>
    <%
    /* Note: MySQL is accessed through port 3306. NAIJA is the name of the database */
         String connectionURL = "jdbc:mysql://localhost:3306/buyandsell";
         Connection connection = null;
         Statement statement = null;
    ResultSet rs = null;
    try {
    // Load SQL Server class file
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    // Make a connection to the Mysql
    connection = DriverManager.getConnection(connectionURL, "root", "");
    %>
    <%-- -------- INSERT Code -------- --%>
    <%
    String action = request.getParameter("action");
    // Check if an insertion is requested
    if (action != null && action.equals("insert")) {
    // Begin transaction
    connection.setAutoCommit(false);
    // Create the prepared statement and use it to
    // INSERT the registration attributes INTO the registration table.
    PreparedStatement pstmt = connection.prepareStatement( "INSERT INTO registration(email,Password,Firstname,Lastname,phone,Address,City,Country) VALUES(?,?,?,?,?,?,?,?)");
                   pstmt.setString(1, request.getParameter("email"));
                   pstmt.setString(2, request.getParameter("Password"));
    pstmt.setString(3, request.getParameter("Firstname"));
                   pstmt.setString(4, request.getParameter("Lastname"));
                   pstmt.setDouble(
    5, Double.parseDouble(request.getParameter("phone")));
                   pstmt.setString(6, request.getParameter("Address"));
                   pstmt.setString(7, request.getParameter("City"));
    pstmt.setString(
    8, request.getParameter("Country"));
    int rowCount = pstmt.executeUpdate();
    // Commit transaction
    connection.commit();
    connection.setAutoCommit(true);
    %>
    <p>
    <p>
    <form
                        NAME="data"
                        action="Login.html" method="post">
    <input type="hidden" value="insert" name="action">
    </p>
    Email:
         <strong>
         <%= email %>
         </strong>
    <p>
    Firstname:
         <strong>
         <%= Firstname %>
         </strong>
    </p>
    <p>
    Lastname:
         <strong>
         <%= Lastname %>
         </strong>
    </p>
    <p>
    Phone no:
         <strong>
         "<%= phone %>"
         </strong>
    </p>
    <p>
    Address:
         <strong>
         <%= Address %>
         </strong>
    </p>
    <p>
    City:
         <strong>
         <%= City %>
         </strong>
    </p>
    <p>
    Country:
         <strong>
         <%= Country %>
         </strong>
    </p>
    <p>
    <input type="submit" value="SAVE">
    </form>
    </p>
    <%-- -------- Close Connection Code -------- --%>
    <%
    // Close the ResultSet
    rs.close();
    // Close the Statement
    statement.close();
    // Close the Connection
    connection.close();
    } catch (SQLException sqle) {
    out.println(sqle.getMessage());
    } catch (Exception e) {
    out.println(e.getMessage());
    %>
    </body>
    </html>

    Hi,
    I think in place of buyandsell put NAIJA
    String connectionURL = "jdbc:mysql://localhost:3306/NAIJA ";

  • Why we should use JSP instead of Servlet ?

    I want to know what are the advantages to use JSP over Servlet.

    hi
    Servlets are server exctension ( like CGI ) separate executable
    modules to serve any request efficiently.
    Servlets are pure java classes, u can use them the write an html code to browser.
    u have to compile the servlet before u use it.
    JSP page, is a text-base document , u can type html inside it , and u can use java as scripting language, so it is more easy to use jsp rather than servlet as each jsp page is translated into a servlet by JSP engine.
    Hope this will help
    Good luck
    Mohammed

  • Photo using jsp

    iam using this standrad function module HRWPC_RFC_EP_READ_PHOTO_URI  using JSP i want photo

    Below coding iam using to display image at that u have given some coding where i have to place that
    PrintWriter out = response.getWriter();
                        String from = request.getParameter("num1");
                        //String to = request.getParameter("num2");
                        out.write("Hi servlet");
                        JCO.Client mconnection =
                                  JCO.createClient("180",
                                                           "jshaik",
                                                           "1Q2W3E",
                                                           "EN",
                                                           "150.0.150.141",
                                                           "04");
                             out.write("created client");
                             try{
                                  mconnection.connect();
    //                              out.write("connnected");
                                  JCO.Repository mrepository = new JCO.Repository("JCO Sample",
                                                                          mconnection);
    //                              out.write("connnected");                         
                                  IFunctionTemplate functiontemplate =
                                            mrepository.getFunctionTemplate("HRWPC_RFC_EP_READ_PHOTO_URI");
    //                              out.write("got fn template");
                                  JCO.Function function = functiontemplate.getFunction();
    //                              out.write("got fn template");
                                  function.getImportParameterList().setValue(from, "PERNR");
                                  //function.getImportParameterList().getStructure("DESTINATION_TO").setValue(to,"CITY");
                                  mconnection.execute(function);
    //                              out.write("fn executed");
    //                              JCO.Table mytable = function.getTableParameterList().getTable("FLIGHT_LIST");
    //                              response.setContentType("text/html");
    //                              out.write("<html>" +
    //                                             "<body>" "<table border='2'> "
    //                              "<th> <td> AirLine <td> From City <td> To City<td>Date<td>Price </th>");
    //                              for(int i=0; i<mytable.getNumRows(); i++, mytable.nextRow()){
    //                                   out.write("<tr>");
    //                                   out.write("<td>"(i1));
    //                                   out.write("<td>"+mytable.getString("AIRLINE"));
    //                                   out.write("<td>"+mytable.getString("CITYFROM"));
    //                                   out.write("<td>"+mytable.getString("CITYTO"));
    //                                   out.write("<td>"+mytable.getValue("FLIGHTDATE"));
    //                                   out.write("<td>"+mytable.getValue("PRICE")
    //                                                  + " " + mytable.getValue("CURR"));
    //                              out.write("</body>" +
    //                                          "</html>");
                                  String customer = function.getExportParameterList().getValue("URI").toString();
                                // String customer1 = function.getExportParameterList().getValue("LNAME").toString();
                                             //JCO.Table mytable = function.getTableParameterList().getTable("PERSONALDATA");
                                        response.setContentType("text/html");
                                             out.write("<html>" +
                                                            "<body>" + "URI"  + customer 
                                                             "</body>""</html>");
    //                                                             "<table border='2'> "+
    //                                                        "<th> <td> AirLine <td> From City <td><td><td> </th>");
    //                                                        for(int i=0; i<mytable.getNumRows(); i++, mytable.nextRow()){
    //                                                             out.write("<tr>");
    //                                                             out.write("<td>"(i1));
    //                                                             out.write("<td>"+mytable.getString("PERNR"));
    //                                                             out.write("<td>"+mytable.getString("EMPNAME"));
    //                                                             //out.write("<td>"+mytable.getString("CITYTO"));
    //                                                             //out.write("<td>"+mytable.getValue("FLIGHTDATE"));
    //                                                             //out.write("<td>"+mytable.getValue("PRICE")
    //                                                                            //+ " " + mytable.getValue("CURR"));
    //                                         out.write("</table></body>" +
    //                                                     "</html>");
    //                              out.write(returnstruct.getName());
                             }catch(Exception e){
                                  out.write("exception");
                                  out.write(e.getLocalizedMessage());
                             }finally{
                                  mconnection.disconnect();

Maybe you are looking for