Click to See Complete Forum and Search --> : Servlet is not working Consistently.


Kishore Kumar
October 14th, 1999, 03:05 AM
Hello Friends,
I am having a problem in Servlets. I wrote a servlet to Register(into Database) a perticular person's
details. When in Register a person for first time its working Properly. When I click Back button and
change the details and submit once again, Browser is showing a message "The downloaded file is not
available due to your Language or Securiy Settings". It is working fine in the machine where Servlet
runner is running. But its not working in other machines.
Code for the Servlet is given below.

import java.io.* ;
import java.sql.* ;
import javax.servlet.* ;
import javax.servlet.http.* ;

public class RegisterToDiscussServlet extends HttpServlet
{
public void init( ServletConfig config )
{
System.out.println( "From init() of RegisterToDiscussServlet." ) ;
}

public void doPost( HttpServletRequest req, HttpServletResponse res )
{
PrintWriter toClient ;
String strUserId ;
RegisteredUser User = new RegisteredUser() ;

res.setContentType( "text/html" ) ;

try
{
toClient = res.getWriter() ;
}
catch( Exception e )
{
System.out.println( "Failed to get the Writer of the Client." ) ;

return ;
}

User.setUserIdOnly( req.getParameter( "txtUserId" ) ) ;
User.setPassword( req.getParameter( "txtPassword" ) ) ;
User.setFirstName( req.getParameter( "txtFirstName" ) ) ;
User.setLastName( req.getParameter( "txtLastName" ) ) ;
User.setEmpNumber( req.getParameter( "txtEmpNumber" ) ) ;
User.setAddress( req.getParameter( "txtAddress" ) ) ;
User.setEmail( req.getParameter( "txtEmail" ) ) ;
User.setTelephone( req.getParameter( "txtTelephone" ) ) ;

toClient.println( "<HTML><HEAD><TITLE> Registration Results</TITLE></HEAD>" ) ;
toClient.println( "<BODY><H1> Registration Results</H1><HR>" ) ;

if ( User.isConnectionAlive() )
{
if ( User.writeIntoDatabase() )
{
toClient.println( " Dear " + User.getName() + ",<BR><BR>" ) ;
toClient.println( "You are registered successfully. Your UserId is <B>" + User.getUserId() + "</B>." ) ;
System.out.println( "Dear " + User.getName() + " Registered Successfully From : " + req.getRemoteAddr() ) ;
}
else
{
toClient.println( "Sorry. . . Failed to Register." ) ;
System.out.println( "Sorry. . . Failed to Register " + User.getName() + ", Request From : " + req.getRemoteAddr() ) ;
}
}
else
{
toClient.println( "Sorry. . . Oracle Server is Down, Try after some time." ) ;
System.out.println( "Sorry. . . Oracle Server is Down, Try after some time " + User.getName() + ", Request From : " + req.getRemoteAddr() ) ;
}

toClient.println( "<BR><BR><BR><CENTER>Click here to <A HREF=\"http://32.73.105.128/CaseStudy/Login.html\">Login to Discussion Board</A>.</CENTER>" ) ;

toClient.println( "</BODY></HTML>" ) ;
toClient.close()() ;
User.closeConnection() ;
}

public void destroy()
{
System.out.println( "From Destroy." ) ;
}
}




In this RegisteredUser is a class to intaract with Database.

Please help me.
- Kishore

Bhanu Erraguntla
October 14th, 1999, 03:49 PM
Check the following
Is it browser specific only ie IE or Netscape.
When the user is clicking back and submitting again are you resetting all your variables properly and then re-initiating the user. (cookies for example).
Check if you are getting any exceptions in the log files.
Else provide more details as to what is being done when you are submitting the user.