如何在jsp按钮的属性中运行java rmi程序

时间:2014-02-11 10:49:45

标签: java jsp

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
        <%@page import="com.studytrails.tutorials.springremotingrmiclient.TestSpringRemotingRmi" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body bgcolor="red">
    <h1><font color=blue>login successfull</font></h1>
    <h2><font color="lightgreen">
    <form action="${pageContext.request.contextPath}/MyServlet" method="post">

    <input type=submit name="n1" value="Click here to play the video">

    </form>

    </h2>

    </body>
    </html>

Need to run the below program when clicking the button in jsp file.


    package com.studytrails.tutorials.springremotingrmiclient;
    import java.io.*;

    import java.io.File.*;
    import java.net.Socket;
    import java.net.UnknownHostException;

    import org.springframework.context.ApplicationContext;

    import org.springframework.context.support.ClassPathXmlApplicationContext;
    import org.springframework.core.io.Resource;

    import com.studytrails.tutorials.springremotingrmiserver.*;


    public class TestSpringRemotingRmi 
    {
         public static void main(String[] args) throws IOException 
         {
                ApplicationContext context = new ClassPathXmlApplicationContext("spring-config-client.xml");
                GreetingService greetingService = (GreetingService)context.getBean("greetingService");

                String greetingMessage = greetingService.getGreeting("Alpha");

                System.out.println("The greeting message is : " + greetingMessage);
                greetingService.getText();
         }   

    }

在上面的程序中,我试图在jsp文件中执行按钮单击时运行java TestSpringRemotingRmi类。 MyServlet文件包含用于处理来自jsp文件的请求的代码。但我尝试使用jsp调用该调用的默认构造函数,但它不起作用。指导我解决这个问题。

0 个答案:

没有答案