Click to See Complete Forum and Search --> : Java and HTML forms


Afra_Kitty
11-16-2005, 11:30 AM
Hello,

I am so new that I can't even spell it properly yet.

My intention is to create an HTML interface app with some javascript verification functions and JAVA.
The JAVA part has been done, I hope. It'll be used to do API calls.

My test html screen is just trying to access the JAVA programs, but I have not been successful. I have not been able to find the syntax.

<HTML>
<HEAD>
<TITLE>HtmlPage
</TITLE>
</HEAD>
<BODY>
<FORM METHOD="GET" name=TestOne>
<INPUT id=button1 type=button size=10 value="Get Schedules" name=button1 action='xxx.jsp' >
</FORM>
</BODY>
</HTML>

I am confused as there are two types of files: xxx.java and xxx.jsp
Can I use either one or is one compiled and the other needs to be compiled?

The above code, I thought would be the easiest way to test. Eventually, I will have to go through the javascript functions and then if all is fine, do the JAVA API calls.

I apologize if this question should not be in this category.
Any help is greatly appreciated. My eyes are burning from searching the net.

Oak
11-16-2005, 12:02 PM
xxx.java : Any files with the .java extension are uncompiled files. They contain the source code but have not been transformed by the java compiler into a .class file which contains the bytecode that the java virtual machine can understand.

xxx.jsp : A file with extension .jsp means that it is a script file which will be parsed by the web server. (i.e. run and turned into pure html/javascript)

What you need to do is to first of all compile your .java file into a .class file and then when you want to make a call to an api function from within your jsp you can use the following syntax:

<%@ page import="your.package.YourClass" %>

<%

YourClass yourObject = new YourClass();
yourObject.yourApiCall();

%>

See this link for more details.

http://www.jsptut.com/

See Khalid Ali's sticky post at the top of the forum for classpath problems and basic java setup details.

All the best.

Khalid Ali
11-16-2005, 03:33 PM
in addition to the above, to send any calls infor to server from a client you will need to use Http Request mechanism. By default this is encapsulated in a form's action attribute. Which means you your form tag may look like this

<form action="path/yourJsp.jsp" method="get or post">

or if its a servlet then

<form action="path/yourServlet" method="get or post">

You can add parameters in standard http way with the form field name=value pairs to the urls above in the form and directly send a request(such as via a link) or just submit the form to the url...

This may take some time for you to grasp, however you are on right track.
By the way one more importnat piece of info.
A jsp page is when accessed, compiled to a servlet. Good luck

Afra_Kitty
11-17-2005, 08:59 AM
Thank you kindly to both of you.

I visited the jsp tutorial and it was excellent. Just loved it!. I was able to call a simple jsp form an html form, however both files are on the same path.

For the files I need, the servlet path can't be found. I'll request help from our IT guys, maybe they'll remember it :)

Thanks again.
meow...