Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple servlet problem

Status
Not open for further replies.

aagustin

Programmer
Jul 23, 2001
12
US
Hi, I'm trying to open another page through a servelt and am not getting the desired results, can some one please show me the error of my ways?

SERVLET:

import java.io.*;
import java.applet.*;
import java.awt.*;
import java.awt.Graphics;
import java.net.*;

class Test extends Applet{

public void main () {
try
{

URL url = new URL("AppletContext context = getAppletContext();
context.showDocument(url);
}
catch (MalformedURLException e)
{
}
}
}

HTML:


<HTML>
<BODY>
<APPLET CODE=&quot;Test.class&quot; HEIGHT=100 WIDTH=100> </APPLET>
</BODY>
</HTML>
 
QUESTION: What are your current results... besides undesired.

COMMENT: This is an Applet, not a Servlet. Two completely different things.
 
My mistake, on the Servlet - Applet thing...

I'm not getting redirected to the next web page.
 
If all you are trying to do is redirect then you should be using HTML not Java.
Here is an HTML page using a redirect.
Code:
<HTML>
<HEAD>
  <META HTTP-EQUIV=&quot;REFRESH&quot; CONTENT=&quot;0;URL=http://www.msn.com&quot;>
</HEAD>
<BODY>
</BODY>
</HTML>
 
I need java for a larger applet which verifies login info based on a flat file...is the login info is in the file then I need to redirect them to the next page.
 
You should use servlet checkAcess.java to open the flat file in read only way and check user login again password.
Here are my suggestions
1. Use a html form for inputting user login and password, the action in html should be the servlet checkAcess
2. the servlet check if a user is valid to login. Invalid user should be redirect to another html page by using the servlet .
response.sendRedirect (&quot;/NewUser.html&quot;);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top