I am trying to pass a string variable called seq from a JSP to a Java program, and pass it on to the another Java program by passing the string as an argument to its object. I am somehow getting stuck.
Start.jsp:
<%@ page import="org.dypbbi.nirmiti.ProtModMain %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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>NIRMITI</title>
</head>
<body>
<h1>Please wait...</h1>
<%
String seq=request.getParameter("s");
ProtModMain.getSequence(seq);
%>
</body>
</html>
ProtModMain.java:
package org.dypbbi.nirmiti;
public class ProtModMain {
String sequence="";
public static String getSequence(String str)
{
return str;
}
public static void main(String args[])throws Exception
{
ProtModMain MainObj = new ProtModMain();
sequence = MainObj.getSequence();
new ObjectFactory(sequence);
}
}
Start.jsp will retrieve the string value from the HTML. It passes the string to ProtModMain class via the method getSequence. I now need to use the string value to pass it to other classes that require it, so I intend to pass it a parameter to the ObjectFactory object. But before that, I need to call the getSequence method in the ProtModMain class so that I can pass the value. I am not understanding how to call the getSequence method in the main method of ProtModMain class.
jsps work and how they should be used. Take a look at the wiki for bothjspandservlets