alessandro
alessandro

Reputation: 1721

Parameter Passing Issue with Servlet

I have created a Web Application Project and Java Application Project using NetBeans 6.9. Now, my project structure is like,

Web Application Project 
    WEB-INF
        JSP Page
    Source Package
        Servlet

Java Application Project
     default package
             Java File

Now, I want to pass parameters from Servlet/JSP to Java file (in both direction). Can anybody help me, how can I solve this ? Thanks in advance.

Upvotes: 0

Views: 500

Answers (1)

Mr Moose
Mr Moose

Reputation: 6344

Your parameter passing to the JSP/Servlet will most likely be done via request parameters (or possibly session parameters. This is done in the construction of your query string.

For example;

/mywebapp/MyJsp.jsp?param1=param1Value&param2=param2Value

The same query strings can be used in the case of Servlets. The Servlets simply need to be configured in your web.xml This is done via the <servlet> and <servlet-mapping> tags within the web.xml.

Both the JSP and Servlet files should be able to import and reference the methods of your "Java File" under the default pacakage that you mentioned. The can directly call methods in your classes assuming that the Java file is on your classpath (either as a class file or in a JAR file).

Take a look at some introductory tutorials on developing a web-app and you'll soon get some examples of how this all works.

Upvotes: 1

Related Questions