XSL and WML using servlets

Hi
I am stuck with xsl for wml.I cannot get to see my wml page in any mobile emulator.However I was able to see it in some WAP browsers like winwap etc..
What could be wrong with xsl?I am actually generating wml from xml and xsl passed on to the transformer class in servlet .This works fine for wap browser like winwap but not for any emulators like erricsson,nokia etc..
Please help
Thanks

Actually I am setting header (i.e PUBLIC //WAPFORUM etc)from servlet hence not mentioned here in XSL file.
In servlet:
static void getWmlHeader(java.io.PrintWriter out)
{       out.println("<?xml version=\"1.0\"?>");
     out.println("<!DOCTYPE wml " +
     "PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\"");
     out.println ("\"http://www.wapforum.org/DTD/wml_1.1.xml\">");
XSL File:
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="customer_Id" select="customerInfo/customer/CUSTOMER_ID"/>
<xsl:variable name="product" select="customerInfo/customer/PRODUCT"/>
<wml>
<card id="S3" title="Product Page">
<p align="center">
*<b>Login Successful</b>*
customer Name :<b><xsl:value-of select="customerInfo/customer/CUSTOMER_NAME"/></b>
customer Id :<b><xsl:value-of select="customerInfo/customer/CUSTOMER_ID"/></b>
Item :<b><xsl:value-of select="customerInfo/customer/PRODUCT_ITEM"/></b>
Proceed to register
<a href="/ProductIndex/ItemList?cid={$customer_Id&product={$product">Select Items</a><br/>
<a href="/ProductIndex/Index">HomePage</a><br/>
</p>
</card>
</wml>           
</xsl:template>
</xsl:stylesheet>
Thanks
Ash

Similar Messages

  • Retrieving data from oracle database and displaying using servlets

    //DataRetrieving.class file
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class DataRetrieving extends HttpServlet{
    public void doGet(HttpServletRequest request, HttpServletResponse response)throws
    ServletException, IOException{ 
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("A program for connecting oracle database");
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL", "scott","tiger");
    Statement stmt = con.createStatement();
    ResultSet r = stmt.executeQuery ("SELECT ename,job,sal,comm,deptno FROM emp");
    while ( r.next() )
         String bar = r.getString("ename");
         String bar1 = r.getString("job");
         float bar2 = r.getInt("sal");
         float bar3 = r.getInt("comm");
         int bar4 = r.getInt("deptno");
         //out.println(r.getString(0)+" "+r.getString("ename"));
         out.println("hi");
         out.println(bar1);
    r.close();
    stmt.close();
    con.close();
    catch (Exception e)
    out.println("ERROR : " + e);
    //web.xml file
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!--<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd"> -->
    <web-app>
    <servlet>
    <servlet-name>Hello</servlet-name>
    <servlet-class>DataRetrieving</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Hello</servlet-name>
    <url-pattern>/DataRetrieval</url-pattern>
    </servlet-mapping>
    </web-app>
    while running the servlet , i am unable to retrieve the data
    The error message i am getting is
    A program for connecting oracle database
    ERROR : java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    after running the servlet.
    what could be the problem?

    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class myserv extends HttpServlet
    public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
    res.setContentType("text/html");
    PrintWriter pw=res.getwriter();
    pw.println("Connecting data base");
         try
         Class.forName("oracle.jdbc.driver.OracleDriver");
         Connection con=Drivermanager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger");
         Stamtenet st=con.createStament();
         Resultset rs=con.executeQurey("select * from emp");
         while(rs.next())
         rs.getInt("empno")+" "+rs.getDouble("sal"));
         }catch(Exception e)
    }

  • Detecting ram and hard disk using servlet

    how to detect RAM and HD using servlet from remote client host. currently i use JIGSAW as JWS...should i use hashtable and runtime class for this problems. please help me...

    well...
    You can't...
    You could use the methods in the Runtime class for memory management but they'll return the corresponding values of the server and not the client (Servlets are Server Side Java Applets).
    And most of the hardware specs are hidden to JVM and without JNI programming you are unable to detect any hardware type (HW drivers are usually written in C or even in ASM).
    So, learn C, figure out how to access devices at low level programming if the information is so important for you and stop dreaming of accessing computer hardware from the web. It would be a serious security risk if it would be possible ;)
    rgds
    Sabalasa

  • How to receive parameters from a form and insert values in db using servlet

    Hi friends,
    My first question here.
    I'm trying to create a Servlet that takes input from a form and process it and insert it in database.tablename.
    My MAIN ISSUE IS WITH THE NUMBER OF COLUMNS THAT WOULD BE DYNAMIC AND THUS CANT RECEIVE THE PARAMETERS IN STATIC CODE.
    Here is the form code
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <form action="Test" method="post" />
    <table width="90%" border="1" cellspacing="1" cellpadding="1">
    <tr>
    <th scope="col">Student Name</th>
    <th scope="col">RollNo</th>
    <th scope="col">Java</th>
    <th scope="col">J2ee</th>
    </tr>
    <tr>
    <td><input type="text" name="studentname" /></td>
    <td><input type="text" name="rollno" /></td>
    <td><input type="text" name="java" /></td>
    <td><input type="text" name="j2ee" /></td>
    </tr>
    <tr>
    <td><input type="text" name="studentname" /></td>
    <td><input type="text" name="rollno" /></td>
    <td><input type="text" name="java" /></td>
    <td><input type="text" name="j2ee" /></td>
    </tr>
    <tr>
    <td><input type="text" name="studentname" /></td>
    <td><input type="text" name="rollno" /></td>
    <td><input type="text" name="java" /></td>
    <td><input type="text" name="j2ee" /></td>
    </tr>
    </table>
    <input type ="submit" value="insert values in the database now"/>
    </form>
    </html>
    And here is the Servlet
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.io.*;
    public class Test extends HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Module: Process Result Values from previous page";
    out.println("<html>\n" +
    "<head><title>" + title + "</title></head>\n" +
    "<body>");
              try
                   Class.forName("com.mysql.jdbc.Driver");
                   Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/","root", "root");
                   Statement s = con.createStatement();
    ResultSet res = s.executeQuery("SELECT * FROM dbname.tablename");
    ResultSetMetaData rmeta=res.getMetaData();
    int noofcolumns=rmeta.getColumnCount();
                   if(!con.isClosed())
              catch(Exception e)
    System.out.println("Exception"+e);
    out.println(e);
    if(connectionFlag==1)
    out.println("</body></html>");
    doGet(request, response);
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    This is the basic code structure and I'm trying to figure out this special case with handling the multiple parameters:
    1. I dont' want to use String []a=request.getParameterValues("studentname"); as hard code. The reason being the number of rows will be diyamic and I would like to get the column name and then then use an array of string to take values. But how can I connect these to form a query so that the rows goes on inserted one after other.
    Thanks,
    Mashall

    Thank you for your help.
    I'm something close to it but this segment of code throws a NullPointerException Error. I counted number of rows and columns using the methods getColumnCount() and getColumnName(i).
    ResultSetMetaData md = res.getMetaData(); //Get meta data for the resultset
    int noofcolumns=md.getColumnCount();
    out.println("<br />Number of columns in table (including name and roll number) :::: "+noofcolumns+"<br />");
    for(int i=1;i<=noofcolumns;i++) // access column 1....n
    String columnname = md.getColumnName(i); // get name of column 1....n
    out.println("<br />Current column name ::: "+columnname+"<br />"); //check if the name appear correct.
    String []columndata = request.getParameterValues(columnname); //Get raw value in array
    for(int j=1;j<=rows;j++) // here rows is number of rows in each column
    out.println("To be inserted: <b>"+columndata[j]+"</b> in Row ::: "+j+"<br />");
    //The line above thows null pointer exception.
    }

  • XSL-TEXT: how to import subtemplates in XSL and use xdofx tags?

    Hi,
    I am working on a BI Publisher Report (XML Publisher 5.6.3 in EBS) to generate labels on a label printer. The output needs to be in plain text format, therefore I decided to use the XSL-TEXT template and create my own XSL translation.
    In principle this works pretty fine, but there are two things that worry me a bit:
    1. Does anybody know how I could import other XSL files, like sub-templates in RTF? The problem I have is that I don't know the URI or the sub-template. At the moment I store those other XSL files in the OA_MEDIA folder, but this is not really nice. In RFT you can refer to subtemplates with some xdofx commands... this brings me to my second question:
    2. In RTF templates you can use the Oracle specific XML tags, including the <xdofx:%> and <xdoxslt:%> tags. Does anybody know if and how I can use them in XSL templates?
    Any ideas are highly appreciated!
    regards,
    David.

    Hi Vetsrini,
    1. but what is the absolute path for my subtemplates if I store them in the Template Manager? How can I refer to them?
    This is what the manual says for RTFs:
    >
    Enter the Import Syntax in the Primary Template
    Import the subtemplate to the primary template by entering the following syntax in the
    primary template. The import syntax tells the XML Publisher engine where to find the
    subtemplate RTF in the Template Manager. This syntax may be entered anywhere in the
    template prior to the call-template syntax:
    <?import:xdo://APPCODE.TEMPLATE_CODE.lang.TERR?>
    where
    APPCODE is the Application code you assigned to the subtemplate in the Template
    Manager. For example, if you associated this template with the Receivables application,
    enter "AR".
    TEMPLATE_CODE is the template Code you assigned to the subtemplate in the Template
    Manager. For example, AR_CommonComponents.
    >
    sounds good and easy to me. But I don't have a RTF template. I have just a plain XSLT and those XML Publisher tags do not work there. So how do I get the absolute path of my XSLT templates stored in the Template Manager?
    2. I've included the namespace, no error anymore. But the syntax does not result in actions:
    <xsl:value-of select="xdoxslt:substr((PRODUCT_NAME),1,2)"/>
    {code}
    This does not substring() my string, the full string is returned. But anyway, I don't get an error message anymore. Maybe I just used the wrong XDOXSLT function... I need to search for a list of XDOXSLT functions, but that's not very urgent for now. I think I can do the most with plain XSL and inside the DB itself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Using resourceDescription in SUBSCRIPTIONBUNDLED_Email.xsl and xml's.

    Hello all,
    We are trying to use the Primitive Template "resourceDescription" (as described in "Customizing Notifications"-pdf) in the SUBSCRIPTIONBUNDLED_EMAIL.xsl and SUBSCRIPTIONBUNDLED_en.xml.
    Could anyone urgently let me know if it's possible to use this Primitive Template in the xsl and xml mentioned?
    It looks like the "resourceDescription" is not being passed on to the bundlednotificationdata-section in the xml?
    Any other suggestion in how to get the "resourceDescription" available in Daily Summary Subscription emails?
    Thanks in advance,
    Tim.

    Hello Alan,
    Yes; as far as I know the only way to get your changes to any of the email notification xml files visible is by restarting the server
    The notification email xsl I'm working on is the one for the daily notifications (subscriptionbundled_email.xsl).
    My problem is that it seems that the resourceDescription is not being passed on by the java code that is populating the section in the xml file containg the resource information...
    Unfortunately no confirmation about this yet (raised OSS with SAP as well).
    I'm expecting this resourceDescription to contain the text that you can fill in using standard KM in the Description field of a resource.
    I do wonder how/where your users populate the subject and description fields? Standard SAP KM or custom app?
    Cheers,
    Tim.

  • Using getSessionContext() and getIds() in servlets

    hello
    Problem is getSessionContext() and getIds in servlets are not working at all. I 've a servlet which uses these methods to manupulate sessions what it does'nt work.
    getSessionContext() returns session context under which this servlet is running. through this context i want to access all the sessions which are associated with servlet. this context is used with getIds() to get the ids of different sessions. it returns enumeration. but in my case it is always empty even when there are two browsers have valid sessions going on.
    so please suggest me some way out
    waiting desperately
    thanks

    As long as you created the session, it should have returned the session id. You may need to post some code.
    Bosun

  • When to use jsp,and when to use servlet?

    I think that jsp and servlet can realize the same functions, because when run a jsp, it is transferred to a servlet program, so when to use jsp and when to use servlet?
    I am now developing the input interface for a website, I just use jsp and javabean to connect to weblogic and database, and I didn't use servlet, Is there any unseemliness?
    Thank you!

    IMHO I use servlets to control the flow between my jsp's based on a number of factors in a webapp. For instance, user authorization. If a user has the authorization to conduct various administrative functions on an application (like change user rights, reset passwords etc) they will have access to specific buttons or links on some screens that others will not. I use servlets to establish what access rights a user has and direct them to the appropriate pages. I also use servlets to test data validity on form input screens. I know that I can also do this with JavaScript but that can be disabled by the client and in order to prevent that I also double check the form input from a servlet. All my jsp's do is display the results of a business process (which is held in a JavaBean or EJB) and the servlets act as the controllers for the application, connecting to multiple databases, verifying application state, flow control etc. I try to keep the jsp as simple as possible as some of them are maintained by html developers who lack the necessary experience to write java code. I hope this helps.

  • How can i upload files in servlets and also using jsp

    means that uploading files(.doc) or any files by using servlets and jsps

    yawmark wrote:
    saichand wrote:
    means that uploading files(.doc) or any files by using servlets and jsps
    [http://www.google.com/search?q=How+can+i+upload+files+in+servlets+and+also+using+jsp]
    ~Good topic titles are indeed brilliant search keywords. It's sad to see that it won't even come in the mind of the topicstarters to Google it before posting the topic.

  • When to Use Servlet only, EJB only and, both Servlet And EJB???

    I have a question, If I want to build a Web application. Sometime i found that there is no need to use EJB as Servlet already provide that functionality.
    Can anyone tell me when do I use Pure Servlet? When do I use Pure EJB and, When do I use Both EJB and Servlet???
    I am very interesting in it.
    Thanks.
    Jack

    EJB and servlets are two different things. Trying to compare them doesn't really make sense. A web application is always going to need some way to process Http requests and this in Java is done accomplished through Servlets (or jsp pages which in turn also use servlets).
    EJBs are the basis of distributed cross-platform objects. They are handled through name services and stored in databases. An Entity Bean can be "brought back to life" as long as it's info is stored in a database. Regardless of a server being restarted. All this database support behind an Entity Bean (transactions, queries etc.) are very transparent to the programmer. They are provided by the EJB vendor.
    The class properties of a Servlet (or class-level member variables) are shared among all requests (running thread instances of the service method). That's why they should be used with a lot of caution. This feature can be very useful but if used improperly can also be very vulnerable to security and synchronization issues.
    I'm not an EJB expert but this explanation should give you some idea of what EJBs are all about.

  • File download using servlet and jsp. File Dialog comes twice

    Hi
    I was trying to download a file using servlet. There is a link which calls the servlet. When I click on the link file dialog box comes up. On selecting Open it again shows me the file dialog box. I changed the method from POST to GET and it worked properly.
    My question is why does it work with GET and not with POST. I am aware of the differences between POST and GET but am not able to come to a rational explanation for this behaviour.
    Please if anyone can explain this to me I am going crazy thinking an answer for this.
    Thank you.
    Regards
    Jay

    Hi Jay,
    I also have the same question. Why does it work with GET and not for POST?. If you were able to find the answer please let me know.
    Thank you.
    Regards,
    Aravind

  • User Authentication using Servlet and JSp

    Hi,
    I am developing a web app where i need to implement user Authentication to allow members to view and upload files on a certain directory say /data
    For this i am using a servlet as a controller which then forwads request to other jsps/servlets based on user response. I tried using servlet mapping in web.xml so that all browser requests would be directed to controller servlet and would branch from there on. However the problem all RequestDispatcher.forward() requests redirected to the servlet putting it in a loop.
    Is there another way to achieve this. (Apart from using form-based Basic Authentication).
    I am using Resin 1.2.8 servlet/jsp container.
    Any response as soon as possible would be appreciated.
    Thanks,
    Kushagra

    RequestDispatcher.forward() cause the HTTP request to be sent through the request processing flow as if the original request for the resource being forwarded to.
    It seems the servlet mapping you are talking about in web.xml should be made more specific. i.e. the mapping should be such that only your so called controller servlet will match up.
    You might want to specify the mapping for the controller servlet to be noticeably/effectively different from the mapping for other servlets and JSPs.

  • URGENT.........File Upload using Servlets and jsp

    I am a new servlet programmer.......
    iam using tomcat server......
    can any one pls help in writing code for file upload using servlets and jsp without using multipart class or any other class like that....
    Please URGENT..

    Slow down! "Urgent" is from your perspective alone. I, myself, am not troubled or worried in the least.
    hi ugniss
    thanks for ur reply....sorry i was not
    y i was not asked not to use multipart class or any
    other class like that...is there any other
    possibility to do file uploading from jsp to
    servlet...
    Just as an aside, a JSP is a Servlet. But even if I move beyond that, the question does not make sense. If you want a "JSP to upload to a Servlet", then simply do so in memory. You are still (likely) within the same scope of a given request. However, if instead you are referring to a JSP that is displayed on a browser, then really you are talking about HTML, which is what the browser will receive. And since you are now talking about a browser, your only real, viable option is a multi-part file upload. So, it is either server or it is browser. And either way, the question leads to very established options, as outlined above.
    the main concept is.. in the browser the user selects
    a particular file and clicks the button upload..after
    clicking upload the jsp should sent the file to the
    servlet in streams...there the servlet gets in and
    saves in a server location........this is wat i hav
    to do...
    Okay. So, after reading my previous (redundant) paragraph, we have arrived at the crux of the issue. You have a JSP that will be output as HTML to a client (browser) which you want to upload content to your server (handled by a Servlet). So, you are now stuck again with multi-part. The requirement to not use multi-part is non-sensical. You can overcome it, say, if you write your own applet or standalone Swing client. However, if your users are invoking this functionality from a browser, you are limited by the options that W3C has provided you. Use multi-part.
    is there aby possibilty to do this.....can any one
    pls help....Take the advice to download and review Jakarta Commons FileUpload. Inform your management that their requirement makes no technical sense. Research on your own. There are dozens of examples (and tutorials) on file upload using multi-part. Embrace it. Live it. Love it.
    - Saish

  • Question regarding use of Log and LogFactory in Servlets

    Hi,
    I saw the following code in an application and I would like to know where the log information would be stored. It appears that the log information is not displayed on the screen and was not able to find out where the log files are. The application was created using NetBeans and was using Tomcat. Thanks in advance.
    import org.apache.common.logging.*;
    public class Test extends HttpServlet
    private static final Log log = LogFactory.getLog(Test.class);
    String theHost;
    String theSource;
    public void init (ServletConfig config) throws ServletException
    super.init(config);
    log.info(�debug Enabled: �+log.isDebugEnabled());
    ServletContext context =config.getServletContext();
    this.thisHost=�/Test/�+config.getServletName();
    etc. etc.
    log.info(�thisHost:�+this.thisHost);
    log.debug(�Source:� +theSource());
    etc, etc.
    }

    It depends on what logging system you have set up.
    Commons.logging is an abstraction layer above logging components. It allows your code to use a variety of logging systems. However those logging systems have to be set up and configured by you. This can be via system properties, properties files, XML config files (depends on the logging system and how you use it).
    So you need to figure out which logging system is being used and then configue that system to write the logs
    matfud

  • Parsing DOM with XSL and output as HTML

    In a servlet I am fetching data from DB into an DOM-tree (using ordinary JDBC and building the XML-DOM while fetching rows). This is done in a servlet, and before I response to the browser i use Oracle XML-parser to join my DOM-tree with an XSL-file. If I try to my DOM-tree out before parsing, it contains data. But the parsed DOM only contains XSL-tags, no data. What do I do wrong?
    Here is the code:
    DOMParser parser = new DOMParser();
    parser.setPreserveWhitespace(true);
    //No problem finding the XSL-file...
    URL xslURL = createURL("employee.xsl");
    parser.parse(xslURL);
    xslDoc = parser.getDocument();
    XSLStylesheet xsl = new XSLStylesheet(xslDoc, xslURL);
    XSLProcessor processor = new XSLProcessor();
    processor.showWarnings(true);
    processor.setErrorStream(System.out);
    //XML doc does contain data!!!
    DocumentFragment result =
    processor.processXSL(xsl, xmlDoc);
    xmlOut = new XMLDocument();
    Element root = xmlOut.createElement("root");
    xmlOut.appendChild(root);
    root.appendChild(result);
    xmlOut.print(out); // Result is only the XSL-file.....
    Regards Frank =:>

    Sorry, but I still can not make it work. Here are the XSL and XML-files. My XML test file (which reflects the DOM I am makings
    is:
    <?xml version="1.0" standalone="no"?>
    <!DOCTYPE employees SYSTEM "employee.dtd">
    <?xml:stylesheet type="text/xsl" href="employee.xsl" ?>
    <employees>
    <employee>
    <id>1</id>
    <firstname>Frank</firstname>
    <lastname>Nilsen</lastname>
    </employee>
    <employee>
    <id>2</id>
    <firstname>Ronald</firstname>
    <lastname>Reagen</lastname>
    </employee>
    </employees>
    XSL-file is:
    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    <xsl:template match="/">
    <HTML>
    <BODY>
    <xsl:for-each select="employees/employee">
    <font color="red"><xsl:value-of select="id"/></font>
    <xsl:value-of select="firstname"/>
    <xsl:value-of select="lastname"/>
    </xsl:for-each>
    </BODY>
    </HTML>
    </xsl:template>
    </xsl:stylesheet>
    Regards,
    Frank =:>

Maybe you are looking for