title: Passing a variable from JSP to Java
body: <p>I am trying to pass a string variable called <code>seq</code> from a <a href="http://en.wikipedia.org/wiki/JavaServer_Pages" rel="nofollow">JSP</a> 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.</p>
  
  <p><strong>Start.jsp:</strong></p>
  
  <pre><code>&lt;%@ page import="org.dypbbi.nirmiti.ProtModMain %&gt;
  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
          &lt;title&gt;NIRMITI&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Please wait...&lt;/h1&gt;
          &lt;%
              String seq=request.getParameter("s");
              ProtModMain.getSequence(seq);
          %&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>ProtModMain.java:</strong></p>
  
  <pre><code>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);
      }
  }
  </code></pre>
  
  <p>Start.jsp will retrieve the string value from the <a href="http://en.wikipedia.org/wiki/HTML" rel="nofollow">HTML</a>. It passes the string to <code>ProtModMain</code> class via the method <code>getSequence</code>. 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 <code>ObjectFactory</code> object. But before that, I need to call the <code>getSequence</code> method in the <code>ProtModMain</code> class so that I can pass the value. I am not understanding how to call the <code>getSequence</code> method in the main method of <code>ProtModMain</code> class.</p>