Run a Servlet Without a Submit Button

D

dmckeon

I am new to Java and am trying to figure out how to run a servlet
without the need for a user to click a submit button. I have a web
service that converts a file to PDF and then a servlet that displays
the PDF file in the browser. Here is the code I have in the JSP:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>
<HEAD>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<META name="GENERATOR" content="IBM Software Development Platform">
<META http-equiv="Content-Style-Type" content="text/css">
<LINK href="theme/Master.css" rel="stylesheet"
type="text/css">
<TITLE>IgRetConvTest.jsp</TITLE>
</HEAD>
<BODY>
<H1>Retrieve and Convert</H1>
<jsp:useBean id="proxy"
class="getconvert.IgRetConvProxy"></jsp:useBean>
<%
session.setAttribute("filename",
String.valueOf(proxy.retrieveConvert("<?xml version='1.0'
encoding='UTF-8'
?><IMG-PATH>C:\\\\TEST\\</IMG-PATH><IMG-NAM>TEST.IMG</IMG-NAM>")));

%>
<FORM action="/IgRetConvClient/PDFDisplay" method="post">
<INPUT type="submit" name="Submit" value="Display Image">
</FORM>
</BODY>
</HTML>


How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?
 
O

Oliver Wong

I am new to Java and am trying to figure out how to run a servlet
without the need for a user to click a submit button. I have a web
service that converts a file to PDF and then a servlet that displays
the PDF file in the browser. Here is the code I have in the JSP:

[most of the code snipped]
<FORM action="/IgRetConvClient/PDFDisplay" method="post">
<INPUT type="submit" name="Submit" value="Display Image">
</FORM> [...]


How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?

The user has to somehow navigate to that URL. There are many ways to
this that don't involve clicking on a button labelled "Submit". One of them
is to type in the URL directly into the browser's address bar, for example.

- Oliver
 
D

dmckeon

Oliver said:
I am new to Java and am trying to figure out how to run a servlet
without the need for a user to click a submit button. I have a web
service that converts a file to PDF and then a servlet that displays
the PDF file in the browser. Here is the code I have in the JSP:

[most of the code snipped]
<FORM action="/IgRetConvClient/PDFDisplay" method="post">
<INPUT type="submit" name="Submit" value="Display Image">
</FORM> [...]


How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?

The user has to somehow navigate to that URL. There are many ways to
this that don't involve clicking on a button labelled "Submit". One of them
is to type in the URL directly into the browser's address bar, for example.

- Oliver

All of the code I supplied is in a JSP. If the user navigates to the
JSP I need a way to run the servlet without them clicking "submit".
Can you give me some specific examples of how to do that?
 
O

Oliver Wong

Oliver said:
I am new to Java and am trying to figure out how to run a servlet
without the need for a user to click a submit button. I have a web
service that converts a file to PDF and then a servlet that displays
the PDF file in the browser. Here is the code I have in the JSP:

[most of the code snipped]
<FORM action="/IgRetConvClient/PDFDisplay" method="post">
<INPUT type="submit" name="Submit" value="Display Image">
</FORM> [...]


How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?

The user has to somehow navigate to that URL. There are many ways to
this that don't involve clicking on a button labelled "Submit". One of
them
is to type in the URL directly into the browser's address bar, for
example.

All of the code I supplied is in a JSP. If the user navigates to the
JSP I need a way to run the servlet without them clicking "submit".
Can you give me some specific examples of how to do that?

Doesn't the user navigating directly to
http://[yourserver]/IgRetConvClient/PDFDisplay cause the servlet to run?

- Oliver
 
D

dmckeon

Oliver said:
Oliver said:
I am new to Java and am trying to figure out how to run a servlet
without the need for a user to click a submit button. I have a web
service that converts a file to PDF and then a servlet that displays
the PDF file in the browser. Here is the code I have in the JSP:

[most of the code snipped]
<FORM action="/IgRetConvClient/PDFDisplay" method="post">
<INPUT type="submit" name="Submit" value="Display Image">
</FORM>
[...]


How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?

The user has to somehow navigate to that URL. There are many ways to
this that don't involve clicking on a button labelled "Submit". One of
them
is to type in the URL directly into the browser's address bar, for
example.

All of the code I supplied is in a JSP. If the user navigates to the
JSP I need a way to run the servlet without them clicking "submit".
Can you give me some specific examples of how to do that?

Doesn't the user navigating directly to
http://[yourserver]/IgRetConvClient/PDFDisplay cause the servlet to run?

- Oliver

That's not the way it's structured or the way we need it to work.
 
D

dmckeon

Oliver said:
Oliver said:
I am new to Java and am trying to figure out how to run a servlet
without the need for a user to click a submit button. I have a web
service that converts a file to PDF and then a servlet that displays
the PDF file in the browser. Here is the code I have in the JSP:

[most of the code snipped]
<FORM action="/IgRetConvClient/PDFDisplay" method="post">
<INPUT type="submit" name="Submit" value="Display Image">
</FORM>
[...]


How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?

The user has to somehow navigate to that URL. There are many ways to
this that don't involve clicking on a button labelled "Submit". One of
them
is to type in the URL directly into the browser's address bar, for
example.

All of the code I supplied is in a JSP. If the user navigates to the
JSP I need a way to run the servlet without them clicking "submit".
Can you give me some specific examples of how to do that?

Doesn't the user navigating directly to
http://[yourserver]/IgRetConvClient/PDFDisplay cause the servlet to run?

- Oliver

I'm sorry -- I think I know what you mean. Are you suggesting I use a
redirect???
 
O

Oliver Wong

Oliver said:
Oliver Wong wrote:
I am new to Java and am trying to figure out how to run a servlet
without the need for a user to click a submit button. I have a web
service that converts a file to PDF and then a servlet that displays
the PDF file in the browser. Here is the code I have in the JSP:

[most of the code snipped]
<FORM action="/IgRetConvClient/PDFDisplay" method="post">
<INPUT type="submit" name="Submit" value="Display Image">
</FORM>
[...]


How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?

The user has to somehow navigate to that URL. There are many ways
to
this that don't involve clicking on a button labelled "Submit". One of
them
is to type in the URL directly into the browser's address bar, for
example.


All of the code I supplied is in a JSP. If the user navigates to the
JSP I need a way to run the servlet without them clicking "submit".
Can you give me some specific examples of how to do that?

Doesn't the user navigating directly to
http://[yourserver]/IgRetConvClient/PDFDisplay cause the servlet to run?

- Oliver

I'm sorry -- I think I know what you mean. Are you suggesting I use a
redirect???

Well, I wanted to get a yes-or-no answer to my question to check if my
assumptions were correct. Assuming they ARE correct, what I'm basically
saying is that there is virtually an infinite number of ways to get the
servelet to run, depending on what you want. All that needs to be done is to
ensure that the client eventually navigates to that link.

So you could use a form, or an <a href="/path/to/your/servlet"> link, or
a redirect, or javascript, or an applet, or a ShockWave flash animation, or
a Windows .url shortcut, etc.

- Oliver
 
C

christopher

Google sometimes does it by having an <img> tag href to a servlet that
returns something unimportant to the browser. the <img> tag can have a
size 0 so it does not interrupt the page.
 
S

steen

Oliver said:
I am new to Java and am trying to figure out how to run a servlet
without the need for a user to click a submit button. I have a web
service that converts a file to PDF and then a servlet that displays
the PDF file in the browser. Here is the code I have in the JSP:

[most of the code snipped]
<FORM action="/IgRetConvClient/PDFDisplay" method="post">
<INPUT type="submit" name="Submit" value="Display Image">
</FORM> [...]


How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?

The user has to somehow navigate to that URL. There are many ways to
this that don't involve clicking on a button labelled "Submit". One of them
is to type in the URL directly into the browser's address bar, for example.

- Oliver

All of the code I supplied is in a JSP. If the user navigates to the
JSP I need a way to run the servlet without them clicking "submit".
Can you give me some specific examples of how to do that?

Well if I understand you correctly, just make the following change to
your jsp :
<BODY onLoad="document.forms[0].submit();">

that will cause the form to auto-submit when your jsp is called. No
need for the user to hit a submit button.

(btw. this is more a javascript question)

/Steen
 
D

dmckeon

steen said:
Oliver said:
I am new to Java and am trying to figure out how to run a servlet
without the need for a user to click a submit button. I have a web
service that converts a file to PDF and then a servlet that displays
the PDF file in the browser. Here is the code I have in the JSP:

[most of the code snipped]
<FORM action="/IgRetConvClient/PDFDisplay" method="post">
<INPUT type="submit" name="Submit" value="Display Image">
</FORM>
[...]


How can I run "/IgRetConvClient/PDFDisplay" without using "submit"?

The user has to somehow navigate to that URL. There are many ways to
this that don't involve clicking on a button labelled "Submit". One of them
is to type in the URL directly into the browser's address bar, for example.

- Oliver

All of the code I supplied is in a JSP. If the user navigates to the
JSP I need a way to run the servlet without them clicking "submit".
Can you give me some specific examples of how to do that?

Well if I understand you correctly, just make the following change to
your jsp :
<BODY onLoad="document.forms[0].submit();">

that will cause the form to auto-submit when your jsp is called. No
need for the user to hit a submit button.

(btw. this is more a javascript question)

/Steen

<BODY onLoad="document.forms[0].submit();"> works like a charm!!!
Thanks so much (and sorry for posting in the wrong group)!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top