Connecting databeses with WML and JSP pages..!

I need information about how to connect databases with wap technologies using wml and jsp , I am waiting your resources, codes and helps.. And I would like to remind you , I am beginner about this topic , Only things that I know are Jsp and WML , I have no experience about wap and how to combine wml and jsp , So please be helper while you send your messages , If all your messages contains much detailed and supported complete sources and files , it will more helpfull for me ..
Thanks in Advance.
P.S : 1- ) if you want to contact direclty , mail address : [email protected]
2-) Don't post me complex references' URL , I have already made search on google,yahoo and etc

Additionally , I would like to learn what I have to need for this project .. Now , I already have winwap wap emulator and Websphere Studio.. Do I need special wap server or something else to test my applications..
Please , hurry up .. I really need your helps..
Ergin

Similar Messages

  • Problems with filters and jsp pages.

    I have the following simple filter that checks if there is user information in the session object and redirects accordingly:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class LoginFilter implements Filter
         public void init(FilterConfig filterConfig) {}
         public void destroy() {}
         public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
         throws IOException, ServletException
              System.out.println("filter");
              HttpSession session = ((HttpServletRequest)request).getSession();
              String action = request.getParameter("action");
              if(action != null && !action.equals("login") && !action.equals("wronglogin"))
                   if(session.getAttribute("username") == null)
                        ((HttpServletResponse)response).sendRedirect("index.jsp?action=wronglogin");
                        System.out.println("User not OK, kicking out...");
                   else
                        chain.doFilter(request, response);
                        System.out.println("User OK, letting in...");
              else
                   chain.doFilter(request, response);
    }The filter is mapped to an admin page with the name index.jsp. However, I get an error for every <% and %> tag in the file (there are quite a few) when I use the filter with the page. The page works fine without the filter, and the filter seems to work with pages without scriptlets (without the <% and %> tags). Here is the beginning of the error report:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on tokens, AnnotationName expected instead
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on tokens, delete these tokens
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on token ";", [ expected
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on token ";", [ expected
    An error occurred at line: 6 in the jsp file: /admin/index.jsp
    Generated servlet error:
    Syntax error on token ";", [ expected
    Jasper gives me many errors per <% and %> tag. As you can see there is a <% tag on line 6. Any idea, why this does not work?
    Thanks!
    Message was edited by:
    chincillya

    What is the JSP scriptlet code at line 6 ?
    By looking at the code we can identify if there are any syntax errors, otherwise we can't really guess what might be the problem.

  • Message bundles accessed from JSF and JSP pages

    Hello, everybody!
    I'm developing a localized JSF application. It is working pretty well until now.
    These are my message files:
    mensagens.properties
    mensagens_en_US.propertiesThis is how they're configured in faces-config.xml:
    <application>
        <resource-bundle>
            <base-name>br.urca.www.biblioteca.web.mensagens</base-name>
            <var>msg</var>
        </resource-bundle>
    </application>And this is how I access the messages in a page:
    <h:outputText value="#{msg.titulo}" />Nothing new until now. But now there was a need for me to have a raw jsp page in
    my web application. This page is displaying ok but I also need to access the
    message bundles as I'm able to access in the normal jsp with the JSF components.
    As you should know I can't use something like the above code with an +<h:outputText>+
    to access the messages because this is a JSF component and I'll not be able to use
    JSF components with this raw jsp page.
    So, my question is: how do I access my localized messages from a raw jsp page? I
    suppose there should be a way to do this, but unfortunately I started programming
    to the web world in Java with JSF, not JSP, so I don't know how to do this with
    JSP.
    Thank you very much.
    Marcos

    BalusC wrote:
    Just include [jstl-1.2.jar|https://maven-repository.dev.java.net/repository/jstl/jars/] in your classpath and define the fmt taglib in your JSP. Nothing more is needed.
    Hello, BalusC. Thank you for your help. We're almost there. After I have included the jstl-1.2.jar you provided me I can use the fmt tag and access message bundles from my raw jsp page (even though I had to provide other message bundles instead of the ones that I use in the other jsf pages, but it's better than nothing).
    Now there just on problem to be fixed. The jsp page is not aware when I change the locale of my application. I change this locale in a jsf page.
    I have this component:
    <h:selectOneMenu value="#{pesquisaAcervo.idiomaAplicacao}"
        valueChangeListener="# {pesquisaAcervo.idiomaAplicacaoMudado}" onchange="submit();">
        <f:selectItems value="#{pesquisaAcervo.idiomasAplicacao}" />
    </h:selectOneMenu>that calls this event in my backing bean class:
    public void idiomaAplicacaoMudado(ValueChangeEvent e)
        fIdiomaAplicacao.liberarItens();
        Idioma idioma = Idioma.deString(e.getNewValue().toString());
        // This line is for JSF
        FacesContext.getCurrentInstance().getViewRoot().setLocale(idioma.localidade());
        // This line is for Tiles
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().
            put(org.apache.tiles.locale.impl.DefaultLocaleResolver.LOCALE_KEY, idioma.localidade());
    }So, do I have to include another line in the idiomaAplicacaoMudado event above in order for the jsp page load the correct resource bundle? Or what else do I have to do?
    Thank you.
    Marcos

  • SAP connector and Jsp page

    hi Experts,
    Can anyone please send me a working example project for SAP connector and Jsp page at [email protected]
    Regards,
    Sanjyoti.

    Hi, 
    Use this example
    import com.sapportals.connector.ConnectorException;
    import com.sapportals.connector.connection.IConnection;
    import com.sapportals.connector.execution.objects.INativeQuery;
    import com.sapportals.connector.execution.objects.InvalidQueryStringException;
    import com.sapportals.connector.execution.objects.QueryExecutionException;
    import com.sapportals.connector.metadata.CapabilityNotSupportedException;
    import com.sapportals.portal.ivs.cg.ConnectionProperties;
    import com.sapportals.portal.ivs.cg.IConnectorGatewayService;
    import com.sapportals.portal.ivs.cg.IConnectorService;
    import com.sapportals.portal.prt.component.*;
    import com.sapportals.portal.prt.resource.ResourceException;
    import com.sapportals.portal.prt.runtime.PortalRuntime;
    public class TestJDBC extends AbstractPortalComponent
    public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
    throws ResourceException
    // Open a connection
    IConnectorGatewayService cgService = (IConnectorGatewayService)
    PortalRuntime.getRuntimeResources().getService(IConnectorService.KEY);
    ConnectionProperties prop = new ConnectionProperties(request.getLocale(),
    request.getUser());
    IConnection client = null;
    try {
    client = cgService.getConnection("System1", prop);
    } catch (Exception e) {
    response.write(e.toString());
    return;
    try {
    // Issue SQL Query statement
    INativeQuery query = client.newNativeQuery();
    String queryStr = "SELECT [CategoryID], [CategoryName], [Description] FROM
    [Categories]";
    //IQuery query = client.newQuery();
    //query.execute(queryStr);
    Object result = query.execute(queryStr);
    //ResultSet singleResult = ((ResultSet) result).getRow();
    //IRecordSet result = query.retrieveRecordSet();
    // Iterate returned result
    ResultSetMetaData recordMetaData = ((ResultSet)result).getMetaData();
    int colNum = recordMetaData.getColumnCount();
    //result.beforeFirst();
    while (((ResultSet)result).next()) {
    for (int i = 1; i <= colNum; i++) {
    response.write(((ResultSet)result).getString(i) + "<br>");
    // Close the connection
    client.close();
    } catch (QueryExecutionException e) {
    response.write(e.toString());
    } catch (CapabilityNotSupportedException e) {
    response.write(e.toString());
    } catch (ConnectorException e) {
    response.write(e.toString());
    } catch (InvalidQueryStringException e) {
    response.write(e.toString());
    } catch (ResourceException e) {
    response.write(e.toString());
    } catch (SQLException e){
    response.write(e.toString());
    }catch(Exception e){
    response.write(e.toString());

  • Printing from web pages is excruciatingly slow with most recent upgrades of Firefox .Use an iMac and an HP officejet printer. Printer works fine with Safari and woodprocessed files, but not with Firefox and web pages.

    Printing from web pages is excruciatingly slow since downloading most recent upgrades of Firefox Mozilla. I have a desktop iMac, OS 10.6.8, and an HP officejet printer 4500 G510n. The printer works fine with the Safari Browser and with woodprocessed files, but not with Firefox and web pages. Help please! It used to print fast with earlier versions of Firefox.

    Hello and welcome to the Apple Discussions Forum.
    I have hardly any experience with HP printers but since your posting has not been replied to yet I thought I'd offer some assistance.
    With the printer status and ink levels working, it shows that you have a connection to the printer. So I would look at the issue being with the protocol being used for the print queue on the Mac.
    Since you have XP and Vista working, I would check the printer queue configuration on either box. In XP, go to the Properties and select Ports. Click the Configure Port tab to view the connection. If you are using RAW, then this is known as HP Jetdirect-Socket on OS X. So if you are not sure what protocol was used before I would create another printer queue, this time selecting IP > HP Jetdirect-Socket. Then enter your IP address and select the K5400dn from the Print Using menu.
    If this still fails to print then please reply. There may be limitations with adding the HP driver this way that I am not aware of. There may also be other driver options you can look at, such as HPIJS. If Greg Sahli reads this posting he has expert knowledge on this matter and will be able to offer some guidance.
    PaHu

  • Quick Look PDF with vertical and horizontal pages

    Is there any way to make Quick Look preview a PDF file with vertical and horizontal pages without adding white padding and retaining the aspect ratio?
    Now, if I have a PDF with page 1 vertical and the other pages horizontal QL shows the latter also with the ratio of a vertical page and adds white padding at their top and bottom. You get the inverse output if the first page is horizontally oriented, but the rest are vertical.

    Word renders print jobs that change the orientation as separate print jobs. So, each print job becomes its own PDF.
    You can make an Automator workflow to combine PDFs. I’m not sure how it decides the order it combines them, so you’d have to experiment.
    This is built as an Application where you’d drop all of the PDFs onto the App icon and it will open the combined PDF where you can edit, name, and save.

  • How to master good design with EJB and JSP?

    I use JSP to calling EJB. But the .jsp file is complex and it's difficult to maintain...I just want to work higher efficent with EJB,JSP and JavaBean. I want to know is there a good design with EJB and JSP? and is there any good material about MVC for EJB,JSP and JavaBean?

    You should read the J2EE blueprint available on this website. Better download the PDF, and print it for yourself so you can read it anytime.

  • CSS Rollover Menu with Images and Current Page Indicator

    Hello.
    I have found a very interesting video here: http://www.youtube.com/watch?v=vv8cRYGCvIY about creating a CSS Rollover Menu with Images and Current Page Indicator (I tested it and it is working fine).
    I have a web site with 15 pages based on a template and I want to use that video sample to do the same thing on my web site.
    Please tell me if I can use the sample from the link above to do that.
    What should I change in the css file (what new class should I make) to make this work on a web site based on a template  ?
    Thank You !

    I don't know about that video tutorial but a sitewide persistent menu indicator ('you are here' highlighting) is very simple to do with CSS classes.
    Details and code examples below:
    http://alt-web.com/Articles/Persistent-Page-Indicator.shtml
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • Where do I get started with OAS and JSP ?

    Where do I get started with OAS and JSP ?
    Resources?
    Please point me in the right direction!
    Post and/or email me at [email protected]

    The simplest way is to read OAS4082 Documentation:
    Developer's Guide: JServlet and JSP Applications.

  • Help With Integrating Servlet and JSP Page?

    Hello There
    --i made jsp page that contain name and description fields and add button
    --and i made servlet that contain the code to insert name and description in the database
    --and i want to make that when the user hit the add button
    -->the entered name and description is sent to the servlet
    and the servlet sent them to database?
    here's what i 've done:
    the jsp code:
    <html:html locale="true">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>
            Categories Page
           </title>
            <html:base/>
        </head>
        <body style="background-color: white">
        <form action="jpage.jsp" method="get">
            <h1>
                <center>
    categories Operations
                </center>
            </h1>
            <h3>
                 <label>Name</label>
            <input type="text" name="name" value="" size="10" />
                 <label>Description</label>
             <input type="text" name="description" value="" size="10" />
             <input type="submit" value="Add" name="button" />
           </h3>
       </form>
        </body>
    </html:html>the servlet code:
    import java.io.*;
    import java.util.Enumeration;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.net.*;
    class NewServlet1 extends HttpServlet{
         Connection conn;
         private ServletConfig config;
    public void init(ServletConfig config)
      throws ServletException{
         this.config=config;
    public void service (HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
       HttpSession session = req.getSession(true);
       res.setContentType("text/html");
    try{
         Class.forName("com.mysql.jdbc.Driver");
       conn = DriverManager.getConnection("jdbc:mysql://localhost/struts", "root", "");
         PreparedStatement ps;
       ps = conn.prepareStatement ("INSERT INTO categories (Name, Description) VALUES(?,?)");
          ps.setString (1, "aa");
          ps.setString (3, "bb");
          ps.executeUpdate();
          ps.close();
          conn.close();
      }catch(Exception e){ e.getMessage();}
      public void destroy(){}
    }

    The JSP Code:
    <html:html locale="true">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>
            Categories Page
           </title>
            <html:base/>
        </head>
        <body style="background-color: white">
        <form action="actionServlet.do?action=Additem" method="*post*">
            <h1>
                <center>
    categories Operations
                </center>
            </h1>
            <h3>
                 <label>Name</label>
            <input type="text" name="name" value="" size="10" />
                 <label>Description</label>
             <input type="text" name="description" value="" size="10" />
             <input type="button" value="Submit">
           </h3>
       </form>
        </body>
    </html:html>The Servlet Code:
    import java.io.*;
    import java.util.Enumeration;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.net.*;
    public class NewServlet1 extends HttpServlet implements SingleThreadModel {
        public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException {
            doPost(request,response);
        public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException {
              String action = request.getParameter("action"); // action = "Additem"
              if (action.equals("Additem")) {
                   String name = request.getParameter("name");
                   String description = request.getParameter("description");
                         RequestDispatcher reqDisp = null;
                   try{
                  Connection conn;
                  PreparedStatement ps;
         Class.forName("com.mysql.jdbc.Driver");
       conn = DriverManager.getConnection("jdbc:mysql://localhost/struts", "root", "");
       ps = conn.prepareStatement ("INSERT INTO categories (Name, Description) VALUES(?,?)");
          ps.setString (1, name);
          ps.setString (3, description);
          ps.executeUpdate();
          ps.close();
          conn.close();
          reqDisp= request.getRequestDispatcher("./index.jsp");
          reqDisp.forward(request, response);
                   catch (Exception ex){
                        System.out.println("Error: "+ ex);
    }The web.xml code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
        <servlet>
            <servlet-name>action</servlet-name>
            <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
            <init-param>
                <param-name>config</param-name>
                <param-value>/WEB-INF/struts-config.xml</param-value>
            </init-param>
            <init-param>
                <param-name>debug</param-name>
                <param-value>2</param-value>
            </init-param>
            <init-param>
                <param-name>detail</param-name>
                <param-value>2</param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
            </servlet>
        <servlet>
            <servlet-name>NewServlet1</servlet-name>
            <servlet-class>NewServlet1</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>action</servlet-name>
            <url-pattern>*.do</url-pattern>
        </servlet-mapping>
        <servlet-mapping>
            <servlet-name>NewServlet1</servlet-name>
            <url-pattern>/NewServlet1</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
            </welcome-file-list>
            <servlet>
         <servlet-name>actionServlet</servlet-name>
         <servlet-class>com.test.servlet.NewServlet1</servlet-class>
    </servlet>
    <servlet-mapping>
         <servlet-name>actionServlet</servlet-name>
         <url-pattern>*.do</url-pattern>
    </servlet-mapping>
        </web-app>

  • Problem with JNDI and JSP in Tomcat

    Hi,
    Basically, what I've done is to use the Tomcat administration web
    application to create the DataSource, which looks like it populated the
    server.xml (see below). I then try to access the testconn.jsp, and am
    getting that "Name java:comp is not bound in this Context" error.
    I was wondering if anyone could tell me what I'm doing wrong?
    Thanks,
    Feri
    My Configuration:
    - Tomcat 5.0.19
    - MySQL 4.0.18-nt
    - mysql-connector-java-3.0.15-ga-bin.jar
    server.xml:
    <GlobalNamingResources>
    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    <!-- Editable user database that can also be used by
    UserDatabaseRealm to authenticate users -->
    <Resource name="UserDatabase" auth="Container"
    type="org.apache.catalina.UserDatabase"
    description="User database that can be updated and saved">
    </Resource>
    <ResourceParams name="UserDatabase">
    <parameter>
    <name>factory</name>
    <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
    </parameter>
    <parameter>
    <name>pathname</name>
    <value>conf/tomcat-users.xml</value>
    </parameter>
    </ResourceParams>
    <!--Feri test JNDI-->
         <Context crossContext="true" debug="5" docBase="injury" path="/injury" reloadable="true">
         <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_injury_log." suffix=".txt" timestamp="true"/>
              <Resource name="jdbc/injury" auth="Container"
    type="javax.sql.DataSource">
    </Resource>
    <ResourceParams name="jdbc/injury">
         <parameter>
              <name>factory</name>
              <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
         </parameter>
    <parameter>
    <name>username</name>
    <value>root</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>root</value>
    </parameter>
         <parameter>
    <name>driverClassName</name>
    <value>com.mysql.jdbc.Driver</value>
    </parameter>
         <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/injury</value>
    </parameter>
         <parameter>
              <name>maxIdle</name>
              <value>30</value>
         </parameter>
         <parameter>
              <name>maxActive</name>
              <value>10</value>
         </parameter>
         <parameter>
              <name>maxWait</name>
              <value>10000</value>
         </parameter>
    </ResourceParams>
         </Context>
    <!--Feri test JNDI end-->
    </GlobalNamingResources>
    \webapps\injury\WEB-INF\web.xml:
    <resource-ref>
    <description>Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file.</description>
    <res-ref-name>jdbc/injury</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    \webapps\injury\testconn.jsp
    <%@ page import="java.sql.*" %>
    <%@ page import="javax.sql.*" %>
    <%@ taglib prefix="ct" uri="/injury" %>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
    <h1>Connection test</h1>
    <ct:connection name="jdbc/injury">
    <%
    Statement stmt= conn.createStatement();
    ResultSet rs;
    rs = stmt.executeQuery("select * from user");
    while (rs.next()){
    %><%=rs.getString(1)%><%=rs.getInt(2) %><br><%
    rs.close();
    stmt.close();
    %>
    </ct:connection>
    ConnectionTag.java
    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    import javax.naming.*;
    import javax.sql.*;
    import javax.sql.DataSource;
    public class ConnectionTag extends TagSupport implements TryCatchFinally {
    private Connection conn;
    // JNDI name of the connection
    private String name;
    public void setName(String name)
         this.name = name;
    public int doStartTag()
         throws JspException
         try {
         Context env = (Context) new InitialContext().lookup("java:comp/env");
         DataSource ds = (DataSource) env.lookup(name);
         if (ds != null)
              conn = ds.getConnection();
         } catch (Exception e) {
         throw new JspException(e);
         if (conn == null)
         throw new JspException("can't open connection " + name);
         pageContext.setAttribute("conn", conn);
         return EVAL_BODY_INCLUDE;
    public void doCatch(Throwable t)
         throws Throwable
         throw t;
    public void doFinally()
         try {
         Connection conn = this.conn;
         this.conn = null;
         pageContext.removeAttribute("conn");
         conn.close();
         } catch (Exception e) {
    Tomcat 5.0\conf\Catalina\localhost\injury.xml
    <?xml version='1.0' encoding='utf-8'?>
    <Context displayName="Injury" docBase="E:\Tomcat 5.0\webapps\injury" path="/injury" className="org.apache.catalina.core.StandardContext"
    cachingAllowed="true" charsetMapperClass="org.apache.catalina .util.CharsetMapper" cookies="true" crossContext="false" debug="0"
    mapperClass="org.apache.catalina.core.StandardContextMapper" useNaming="true" wrapperClass="org.apache.catalina.core.StandardWrapper" >
    <Resource auth="Container" description="Resource reference to a factory for java.sql.Connection instances that may be used for talking to a particular database that is configured in the server.xml file." name="jdbc/injury" type="javax.sql.DataSource"/>
    <ResourceLink global="jdbc/injury" name="injury" type="javax.sql.DataSource"/>
    </Context>

    Hi,
    First of all, you can find alot of information about this in the forum about jsp's.
    I think a good thing to do is not to put your context tag directly into the server.xml file.
    What you should do is create a context.xml file with the context-tag in it, and put it in the META-INF directory of your .war file. Upon deployment to tomcat5 this file will be extracted from the war, copied to the conf\enginename\hostname directory, and it will be renamed to contextName.xml.
    I think you are developing directly into the webapps directory, and I believe you should avoid that and use the deployment feature of the manager web-app or you should use the deployertool from you ide or standalone ant.
    anyway, for starters try to remove the context tag from the server.xml file as described above, and check out the jsp / jdbc forums for simular problems and answers.
    good luck

  • Java File and JSP Page

    I am to create a link verification program -- a simple java file with the database connection & some business logic and a JSP page that instantiates the my java file. It won't work. Everytime I run the jsp page, it gives me java.lang.NullPointerException. Can anyone give me some directions? The web server I am using is JRun.
    Thank you
    Below are my code:
    JSP Page:
    <%--      Verify Links
    --%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <%@ page import="java.sql.*" %>
    <%@ page import="java.net.*" %>
    <%@ page import="pro.*" %>
    <html>
    <head>
    <title>Results</title>
    </head>
    <body>
    <%
    try{
    LinkConnection newconn = new LinkConnection();
    newconn.initialize();
    newconn.query();
    newconn.close();
    }catch (ClassNotFoundException cnfe)
    out.println(cnfe);
    catch (SQLException sqle)
    out.println(sqle);
    catch (NullPointerException npe)
    out.println(npe);
    %>
    </body>
    </html>
    Java Code:
    package pro;
    import java.io.*;
    import java.sql.*;
    import java.net.*;
    public class LinkConnection {
    Connection con;
    ResultSet RS;
    Statement Stmt;
    public void initialize() throws SQLException, ClassNotFoundException
    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("XXXX", "XXXX", "XXXX");
    public void query() throws SQLException
    Statement Stmt=con.createStatement();
    String strSQL="Select guideline_name, guideline_url from pgt_guidelines";
    ResultSet RS=Stmt.executeQuery(strSQL);
    while (RS.next())
    String guidelinename = RS.getString("guideline_name");
    String guidelineurl = ("http://" + RS.getString("guideline_url"));
    try {
    URL url = new URL(guidelineurl);
    HttpURLConnection link=(HttpURLConnection)url.openConnection();
    System.out.println("<font color='blue'>");
    System.out.println(guidelinename);
    System.out.println("<br>");
    System.out.println(guidelineurl);
    System.out.println("</font>");
    System.out.println("<font color='red'>");
    System.out.println(link.getResponseCode());
    System.out.println("</font>");
    System.out.println("<br />");
              }catch (Exception e)
              {System.out.println("<font color='yellow'>Error Link </font>")
    public void close() throws SQLException {     
    RS.close();
    Stmt.close();
    con.close();

    i'm having the same problem, what is the solution to this
    A Servlet Exception Has Occurred
    java.lang.NullPointerException
         at test.Lesson.runSql(Lesson.java:80)
    ===== Lesson.java file =====
    package test;
    import java.sql.* ;
    import java.io.Serializable;
    public class Lesson {
         public Lesson( ) { }
    //Line 9
         public String runSql ( ) {
              String browserOutput = "";
              Connection sqlca = null;
              Statement sqlStatement = null;
              ResultSet myResultSet = null;
    //Line 16
              /* Connect to database, run SQL and produce output */
              try { 
                   /* Connection to the database */
                   Class.forName("org.gjt.mm.mysql.Driver").newInstance();
                   String theDatabase ="jdbc:mysql://localhost/employee";
                   sqlca = DriverManager.getConnection(theDatabase,"usr","pwd");
    //Line 24
                   /* Construct and execute the sql, positioning before the
                   first row in the result set */
                   sqlStatement = sqlca.createStatement();
                   myResultSet = sqlStatement.executeQuery
    //Line 29
                   ("select emp_id, " +
                        "emp_lname, " +
                        "city, " +
                        "state," +
                        "zip_code, " +
                        "emp_fname " +
                        "from employee " +
                        "where emp_id < 250 " +
                        "order by emp_lname, emp_fname");
    //Line 39
                   /* Construct the heading for the table */
                   browserOutput =
                        "<div align=left>"+
                        "<table border=0 align=left width=520>" +
                        "<caption><i><b>" +
                        "Employee Listing</b></i></caption>" ;
    //Line 46
                   /* Construct the column headings for the table */
                   browserOutput +=
                        "<th align=left>Emp_id</th>" +
                        "<th>First Name</th>" +
                        "<th>Last Name</th>" +
                        "<th>City</th>" +
                        "<th>State</th>" +
                        "<th>Zip</th>" ;
    //Line 55
                   /* Move to next row and & its contents to the html output */
                   while(myResultSet.next()) {
                        browserOutput += "<TR><TD>" +
                   myResultSet.getObject("emp_id").toString() + "</TD><TD>" +
                   myResultSet.getObject("emp_fname").toString()+"</TD><TD>" +
                   myResultSet.getObject("emp_lname").toString() + "</TD><TD>" +
                   myResultSet.getObject("city").toString() + "</TD><TD>" +
                   myResultSet.getObject("state").toString() + "</TD><TD>" +
                   myResultSet.getObject("zip_code").toString() + "</TD></TR>" ;
    //Line 66
                   }//end of while
                   sqlStatement.close();
                   sqlca.close();
              }//end of try
              catch (SQLException e) {
    //Line 72
                   browserOutput = " Error: SQLException: " + e.getMessage();
                   browserOutput= " Error: SQLState: " + e.getSQLState();
                   browserOutput= " VendorError: " + e.getErrorCode();
              }//end of SQLException
              catch (Exception e) {
                   browserOutput = " Error: JDBC Class creation: " + e.getMessage();
              }//end of Exception
    /**Line 80**/     finally {
                   try { sqlca.close(); }
                   catch(SQLException e) {
                   browserOutput = " Error: Closing connection: " + e.getMessage();
              }//end of finally
         /* Complete the html and return it to the Java Server Page */
         browserOutput += "</table>" + "</div>" ;
         return browserOutput;
         } //end of runSql
    }//end of Lesson

  • Pagination with orcale and jsp

    hi, i m new to java can any one tell me how to do pagination with my this codes
    String sqlCount = null;
    String sql = null;
    sql = "select * from HOME_LEASE_ ";
    sqlCount = "select count(*)from HOME_LEASE_ ";
    Enumeration e = request.getParameterNames();
    int i = 0;
    while(e.hasMoreElements()){
    String name = (String)e.nextElement();
    String search = new String(request.getParameter(name)).toUpperCase();
    if(i != 0 && (!search.isEmpty())){
    sql = sql +" and " + name +" like'" + search + "%'" ;
    sqlCount = sqlCount + " and " name" like '" + search + "%'" ;
    }else if((!search.isEmpty()) && (i == 0) ){
    sql = sql + " where " + name +" like '" + search + "%'" ;
    sqlCount = sqlCount + " where " + name+" like '" + search + "%'" ;
    ++i;
    if((sql != null) && (sqlCount != null)){
    DataAccess dB = new DataAccess();
    Connection conn = dB.getConnection();
    Statement stmtCount = dB.createStmt(conn);
    ResultSet rsCount = dB.executeQuery(sqlCount,stmtCount);
    rsCount.next();
    Statement stmt = dB.createStmt(conn);
    ResultSet rs = dB.executeQuery(sql,stmt);
    <% if(rs == null)
    out.println("<h3>No data found</h3>");
    else
    //out.println(rs.next());
    while(rs.next()) {
    //out.println("inside the result set");
    out.println("<tr>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getInt("phase") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getInt("file_no") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getString("se") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getString("str") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getString("qrno") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getString("typ") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getInt("perno") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getString("name") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getInt("total_plot_area_ocp") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getInt("TOT_PREM_AREA") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getInt("total_construction") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getLong("chargbl_construction") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getLong("add_open_construction") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getLong("TOT_PREM_AREA") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getLong("plinth") + "</a></td>");
    out.println( "<td><a href=survey.jsp?phase="+ rs.getString("phase")+"&file_no="+rs.getString("FILE_NO")+">"+ rs.getLong("std_plot_area") + "</a></td>");
    out.println("</tr>");
    dB.close(rsCount);
    dB.close(stmtCount);
    dB.close(rs);
    dB.close(stmt);
    dB.close(conn);
    }else{
    out.println("<center style=\"background-color:red\">Please enter values in text fields<h1></h1></center>");
    %>

    After examining your code, I think:
    You are not using JSP/HTML properly (using java to write out HTML). You can spend a tremendous amount of time with trial and error approaches in learning a technology and still not get much real understanding for your effort. I suggest a better use of those hours would be spent in reading a book on Java first, then a book on JSP. For a book on JSP, go to amazon.com and search for 'Javaserver pages'. Find a book that isn't too old and that has good reviews. Here is one (although its a bit dated):
    http://www.amazon.com/JavaServer-Pages-Edition-Hans-Bergsten/dp/0596005636/ref=sr_1_1?s=books&ie=UTF8&qid=1338821741&sr=1-1
    As far your database code goes, I suggest you read on-line articles on JDBC on how to get/use/close a database connection in a try/catch/finally block. The article will probably also help you write better SQL too. I don't think your question on pagination should be tackled until you learn JSP.

  • Problem with onload in jsp page

    Hi all,
    I had two jsp pages, a search and a results page. I need to enter some search criteria in the first page and based on that criteria i will be getting the results in the results jsp. Now, when i click the back button in the results page, i need to go to the search page and the values which i entered in the search page needs to be present there. But the problem is i had a javascript function which runs on loading of the search page. This function will set all the values in this search page to empty whenever we go to the search page. I am calling this javascript function as follows in my search jsp page.
    <body onload="setdefaultvalues('<%=name%>');">
    I am having the code for the back button in the results page as follows.
    <INPUT TYPE="button" VALUE='Back' onClick="javascript:history.go(-1);resetvalue(name);" class="button">
    The problem i am facing is whenever i go to the search page by clicking on the back button, the values in the search page are getting empty because of the onload method. There is no way that i can remove this onload method as i require it for setting the values in the search page evrytime i get to that from other modules as it is the main page for my module. So, is there anyway that i can stop this function from executing when i come from the results page or is there any other way that i can store the values in the search page when going from the results page.

    i think you really should have the result page include your search page contents rather than having the user need to click back as you'll end up with all sorts of nightmares in caching & session object management to be honest. if the search page is complex use javascript to hide contents and let the users expand them when they want to re-search.
    however, if you feel you must i would suggest the following:
    in your result page:
    session.setAttribute("userQuery","true"); (you probably actually want to put a container object with the query information in here)
    in your search page you could have something like:
    <body <% session.getAttribute("userQuery")==null { %>onload="setdefaultvalues('<%=name%>');"<% } %>>
    -or-
    <body onload="setdefaultvalues('<%=name%>',<%=session.getAttribute("userQuery")==null?"true":"false"%>);">
    function setdefaultvalues(name,run) { if ( !run ) return;....}
    you'll have to decide when to remove the object though cause once its set its there until the session expires or you remove it.
    hope that helps, good luck!

  • Applet to Applet communication between two seperate threads and jsp pages

    Hi,
    have two java applets running on two separate jsp pages. I am trying to have one applet talk to the other applet. I have tried putting the applets in a static hashtable, but I found out (through trial and error) that the memory is not shared between the applets. Needless to say the appletcontext object will not work as well. I have also tried to put the applet threads into a thread group, but it seems that the second applet can't find the first applet's threads. Is there a funky way that I need to create the threads for the threadgroup? Is there a way or type of object that I can use that will share the static memory between plugins? I am using 1.6 in IE. Or am I looking at this wrong and there is an easy way to do this and I am not seeing it.
    Thanks,
    Marc

    Hi Mylene,
    I hope I have understood your problem correctly. I can try to give you a tip. The times I've had to do a pop-up, for instance to show details or a part of the data in a table, I call a javascript function with the required parameters (an ID for details or an array of rows) when the button is pressed or a link is clicked. The function then builds a URL with all the paremeters and uses it to call the standard window.open function. After that the request is handled "as usual", ie as if you didn't actually do a pop-up but simply displayed a new page. The content of the pop-up is a jsp with all the required code to build the table and/or display the data. The contents of the table or data are retrieved with the help of the parameters sent.
    I'm not sure if the portal kit provides some kind of standard functionality for this, but in the cases I've worked with J2EE solutions this has been the most common way of solving the problem.
    I hope this helps.
    kind regards,
    Dionisios

Maybe you are looking for

  • FileName in Sender File Adapter Module

    Hi Folks, In my sender file adapter have written a module to read the picked file name. The protocol used is NFS. Notice that the file name read in the module has the absolute path, including the directory path. E.g The file name xyz has to be picked

  • Firefox wont start, all soloutions given on website do not work

    I am using Windows XP and the most recent version of Firefox. I was browsing last night and had multiple pages open (the websites were bbc.co.uk, eurogamer.co.uk, ign.co.uk). I clicked on a link for an article and the page started behaving strangely,

  • Using apple tv at two homes

    I own ONE apple tv ... and 2 homes ... with a computer and airport at both homes ... is it possible to move the apple tv from one home to the other and be able to rent movies???

  • IOS 8.0.1 Has Been Pulled by Apple

    Due to the stuck at "No Service" and breaking of Touch ID, Apple pulled the iOS 8.0.1 update from the update servers - it is no longer available. I wonder how quickly they are going to be able to come out with an iOS 8.0.2 and fix all these phones th

  • [SOLVED] Corrupt partition table

    A couple days ago I was transferring large files to my 1TB external Seagate USB drive (NTFS).  It was going smooth then on one file it stopped and Thunar gave an error. When looking at the directory with ls -l the file's attributes were question mark