How to call compiled java class in jsp page??

Discussion in 'Programming' started by spiderman3, Dec 26, 2009.

  1. #1
    this is my jsp page codeing..

    <%@ page import="aaaas.com.Admin" %>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    
    <html>
      <head>
          <title>SuperbCoupons.com</title>
          <link rel="stylesheet" type="text/css" href="style.css" />
          
      </head>
      <body>
    
        <form action="?checklogin" name="login">
            User <input type="text" name="txtUser">
            Password <input type="text" name="txtPwd">
            <input type="submit" name="submit" value="Check">
            <%
                Admin a;
                a = new Admin();
                String iAdminName = a.getAdminName();
                String iAdminPwd = a.getAdminPwd();
                
                if (request.getParameter("submit") == "Check")
                {
                 %>
            Basit 
            <%
                }
            %>
    
        </form>
    
      </body>
    </html>
    HTML:
    this is my java class...

    package aaaas.com;
    
    /**
     * Created by IntelliJ IDEA.
     * User: Administrator
     * Date: Dec 26, 2009
     * Time: 3:30:53 AM
     */
    public class Admin {
        private String adminName;
        private String adminPwd;
    
        public String getAdminName()
        {
            adminName = "admin";
            return adminName;
        }
        public String getAdminPwd()
        {
            adminPwd  = "basit";
            return adminPwd;
        }
        
    }
    
    Code (markup):
    how should i call this class?
     
    spiderman3, Dec 26, 2009 IP
  2. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    METHOD 1:
    Deploy the .class file(s) in your webapp's WEB-INF/class directory.

    METHOD 2:
    Create a JAR file containing the .class file(s) and deploy the JAR file in your webapp's WEB-INF/lib directory.

    With both methods, you will be able to call it as below.
    <%
    Hello h = new Hello();
    out.print(h.say());
    %>
     
    NeoCambell, Dec 28, 2009 IP
  3. spiderman3

    spiderman3 Peon

    Messages:
    177
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ok thanks, i understand,
     
    spiderman3, Jan 4, 2010 IP