aspose file tools*
The moose likes Servlets and the fly likes Problem with JSPs in web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem with JSPs in web application" Watch "Problem with JSPs in web application" New topic
Author

Problem with JSPs in web application

nidhivel raja
Ranch Hand

Joined: Jun 26, 2008
Posts: 36
Hi all
I am developing a web application that manages the data of employees
The following are the jsp files that I am using

Index.jsp(login details )



The Servlet for the above JSP LoginServlet




The above code is working without any errors ,On successful login it takes me to the FirstLinkPage and on invalid login it takes me to the InvalidUserPage.


FirstLinkPage.jsp



InvalidUserPage.jsp




Other jsps that I am using


CreateEmployeePage.jsp



ModifyEmployeePage.jsp



My web.xml is



The Problem

1)The problem that I face here is when I click the link on highlighted link in InvalidUserPage ,I get a page called Welcome.jsp with the two text boxes namely username and password .The password text box has its type as Text and not as password.
2)I don’t know how I got this page

Because I have created only the following JSPs and NOT a JSP called Welcome.jsp
CreateEmployeePage.jsp
Index.jsp
ModifyEmployeePage.jsp
FirstLinkPage.jsp
InvalidUserPage.jsp
3) Whenever I get back to the index jsp by clicking the link on FirstLinkPage jsp, the password text box type is changed to text(making the password visible) .when I give the correct login details after this it goes to Welcome.jsp
Can anyone please help me find a solution to this problem ,Thank you in advance




Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 531

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>OOPS!!! You seem to have entered invalid login credentials try again</h1>
<a > Click here to go back to the login page</a>

</body>
</html>


I doubt, whether you get any highlighted link in InvalidUserPage.jsp, because here there no href only, are you sure, you have posted the correct code...
nidhivel raja
Ranch Hand

Joined: Jun 26, 2008
Posts: 36
Thank you for the reply Mr.Prasad Krishnegowda,

Sorry for the inconvenience,i didn't take notice of that part , but my jsp already has a href parameter in the anchor tag , when i paste my code here in javaranch the href attribute is removed ,i dont know the reason

The tag in my InvalidUser.jsp has href attribute as

The First
tag in my FirstLinkPage has href attribute as

The Second
tag in my FirstLinkPage has href attribute as

The Third
tag in my FirstLinkPage has href attribute as
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 531

When you click on highlighted link, in InvalidUser.jsp, are you sure, you will get welcome.jsp and not index.jsp, because even index.jsp displays you two text boxes... what you see in the url, index or welcome.jsp?
nidhivel raja
Ranch Hand

Joined: Jun 26, 2008
Posts: 36
If I click the link in the InvalidUserPage ,the resulting page has the URL index.jsp and the password textbox has now become an ordinary textbox(the password i enter is now visible).
even if i enter an invalid userid password,it takes me to another page with the URL Welcome.jsp .

Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 531

In all the href in jsp's remove the /, just give the filename like index.jsp and try..
nidhivel raja
Ranch Hand

Joined: Jun 26, 2008
Posts: 36
Hi,
I tried as you said but after removing the '/' when i click the login page link in the InvalidUserPage

i am getting the 404 error com/index.jsp is not available
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 531

where is your login.jsp located, inside WEB-INF or WEB-INF/com. can you post your directory structure here...
nidhivel raja
Ranch Hand

Joined: Jun 26, 2008
Posts: 36
sure,

I have attached directory structure screen shot with this reply,please do refer the attachment and give me your suggestions.



[Thumbnail for directory structure.JPG]

Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 273

nidhivel raja wrote: when i paste my code here in javaranch the href attribute is removed ,i dont know the reason

This has happened to me as well. I think it's a security feature on these forums to help prevent cross-site scripting, etc. If you could, please edit your original post by placing all "<" and ">" with "&lt;" and "&gt;" for all the link tags:


It seems like older versions of your files exist in your deployment environment. Try doing a clean build and then re-deploying your application.


SCJP 6 || SCWCD 5
nidhivel raja
Ranch Hand

Joined: Jun 26, 2008
Posts: 36
Thank you , for the suggestions Mr.Michael Angstadt

It seems like older versions of your files exist in your deployment environment. Try doing a clean build and then re-deploying your application.



I did as you said but i am facing the same problem.I even created a new web application but the problem with the welcome page and the text box exists ,Is there any other solution for this problem


Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 531

when your application takes you to welcome.jsp, click on view source and see the code is matching which jsp or not matching with any jsp at all..
nidhivel raja
Ranch Hand

Joined: Jun 26, 2008
Posts: 36
Hi ,
Sure,
I viewed the source code of the Welcome.jsp,it is the same as another webpage in a different application with the name Welcome.jsp,

The following is the code of the Welcome.jsp


As an alternative, I have deleted the other applications and right now i have created a very simple web app with just three jsp
pages

1)index.jsp
2)WrongUser.jsp
3)Home.jsp
4)LoginServletThree

index.jsp




WrongUser.jsp



Home.jsp




LoginServletThree





The above servlet works fine when i run the webapp ,the Welcome page didnot appear this time(THANKS A LOT for your suggestions ) ,but when i the click the login page link in Home page and the Wronguser page i get a blank page instead of the index page(but the URL is /index.jsp) ......can you please give me a solution for this?
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 531

Is it just a blank page or page not found exception?.. also, check the server logs, to see what it is showing..
nidhivel raja
Ranch Hand

Joined: Jun 26, 2008
Posts: 36
Hi,
I checked the server Tomcat Server 6.0 Log,its not showing any errors,but in the server window ,i got the following exception before startup



Any idea what is the reason for this error?
nidhivel raja
Ranch Hand

Joined: Jun 26, 2008
Posts: 36
Hi Mr.Prasad Krishnegowda& Mr.Michael Angstadt ,

The Problem is solved ,I tried replacing the existing anchor tags with the following attributes,

and it works !!!

Thanks a lot for spending your time in helping me to solve my problem
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 531

you are welcome.. glad you figured out, and it worked.. Also, thank you for posting the worked out solution here..
Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 273

Good to hear!
type proto
Greenhorn

Joined: Dec 31, 2009
Posts: 2
Michael Angstadt wrote:Good to hear!

The same to me!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with JSPs in web application