Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Jsp code to enable and disable certain links using jsp code
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Deb
Jsp code to enable and disable certain links using jsp code
4 Answer(s)      4 years and 4 months ago
Posted in : Java Beginners


Hi Everyone,

I have a doubt in JSP,I have created a web application which has priviledges of a superuser and guest..now if a superuser logs in the page gets redirected to home page where all the links under a menu should be visible and enabled whereas when a guest logs in he should be redirected to the same home page but with only a certain links only visible and enabled. now my doubt is how can i write the code to disable these links..
Can anyone help me?? its really really urgent.................!!
Please :)

Thanks in advance
Debo

Advertisement
View Answers

May 28, 2010 at 12:19 PM


Hi Friend,

Try the following code:

1)login.html:

<html>
<head>
</head>
<body>
<form name="form" method="post" action="http://localhost:8080/examples/jsp/mod.jsp">;
<br><br>
<table align="center"><tr><td><h2>Login Authentication</h2></td></tr></table>
<table width="300px" align="center" style="border:1px solid #000000;background-color:#efefef;">
<tr><td colspan=2></td></tr>
<tr><td colspan=2>&nbsp;</td></tr>
<tr>
<td><b>Login Name</b></td>
<td><input type="text" name="username" value=""></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input type="password" name="password" value=""></td>
</tr>

<tr>
<td></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
<tr>
<td></td>
<td align="right"><a href="register.html">New User?</a></td>
</tr>
</table>
</table>
</form>

</body>
</html>

2)mod.jsp:
<%@page import="java.sql.*"%>
<html>
<body>
<%
String user=request.getParameter("username");
String pass=request.getParameter("password");
%>
<%
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root";, "root");
Statement st=connection.createStatement();
ResultSet rs=st.executeQuery("Select * from user where username='"+user+"' and password='"+pass+"'");
String username="";
String pwd="",type="";
while(rs.next()){
username=rs.getString("username");
pwd=rs.getString("password") ;
type=rs.getString("type") ;
}
if(user.equals(username)&&pass.equals(pwd)){
response.sendRedirect("home.jsp?user="+user+"&&type="+type);

}
else
{
response.sendRedirect("login.html");
}
}
catch(Exception e)
{}
%>
</body>
</html>

3)home.jsp:

<%
String name=request.getParameter("user");
String type=request.getParameter("type");
System.out.println(type);
%>
Welcome <%=name%>,<br><br>
<%
if(type.equals("superuser")){
%>
<a id="one" href="edit.jsp">Edit Profile</a><br>
<a id="two" href="view.jsp">View Profile</a><br>
<a id="three" href="delete.jsp">Delete Profile</a>
<%
}
else{
%>
<a id="two" href="view.jsp">View Profile</a><br>
<%
}
%>

Thanks


May 28, 2010 at 12:56 PM


Thank u so much....I will try to use this code to get some help... :)


May 28, 2010 at 12:57 PM


Thank u so much....I will try to use this code to get some help... :)


May 28, 2010 at 1:22 PM


Hi,

As per the code u posted i tried to apply it...but i have used sessions in my code.For the particular session used i have to enable/disable a link.I need a code to do that.

Thanks in advance :)


Related Tutorials/Questions & Answers:
Jsp code to enable and disable certain links using jsp code - Java Beginners
Jsp code to enable and disable certain links using jsp code  Hi... write the code to disable these links.. Can anyone help me?? its really really... have to enable/disable a link.I need a code to do that. Thanks in advance
how to enable and disable a input type in jsp - JSP-Servlet
how to enable and disable a input type in jsp  how to disable the input type and enable based on some input in the input type   Hi Friend, Try the following code: function function1(){ var n
Advertisements
tree using jsp code
tree using jsp code  i want to draw a tree structure of a family hierarchy using jsp code
online shopping code using jsp
online shopping code using jsp  plz send me the code of online shopping using jsp or jdbc or servlets plz plz help me
jsp code
jsp code  hi i am Ruchi can anybody plz tell me the jsp code for searching fromwhole database. I am using Oracle10g Database.   Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http
database connectivity using jsp code
database connectivity using jsp code  i have two tables employee...),'bbbb','bbbb'); so this syntax is possible to use in jsp code based on employee id ename and designation are displayed how it is possible in jsp employee
jsp code
jsp code  what are the jsp code for view page in online journal
JSP CODE
JSP CODE  what is the code for downloading images from database using JSP?   Please visit the following link: http://www.roseindia.net/jsp/downloadimage.shtml
jsp code
jsp code  i want health management system project code using jsp.its urgent
enable disable checkbox in javascript
enable disable checkbox in javascript  How to enable disable checkbox in javascript
JSP CODE
JSP CODE  Please help me as soon as possible.Its Urgent. I am working on my college ALUMNI PORTAL. I want to have a ADD FRIEND option in a user's profile. Please send me code
jsp code
jsp code  i want to jsp code which are working as,i have three drop down menu 1st menu for class second menu for subject and third menu as chapter... according to selectde menu,,,,please send me such type code,,,,plz help me
code for password strength using jsp-servlet
code for password strength using jsp-servlet  hi.............. plz help me to give code for password strength using jsp-servlet for implementation in my project as soon as possible because i want to show this functionality in my
code to send sms alerts using jsp online
code to send sms alerts using jsp online  I am new to mobile aplication development. pls send me the code for sms alerts after clicking the button
jsp code - JSP-Servlet
jsp code  I need code for bar charts using jsp. I searched some code but they are contain some of their own packages. Please give me asimple code... friend, Code to solve the problem : Thanks
code to disable back button of browser
code to disable back button of browser  code to disable back button of browser
code to disable back button of browser
code to disable back button of browser  code to disable back button of browser
JSP code
JSP code  I get an error when i execute the following code : <... = con.createStatement(); st.executeQuery(query); %> <jsp:forward page="address.jsp"></jsp:forward> HTTP Status 500 - type Exception report message
jsp code - JSP-Servlet
jsp code  how to count no of clicks made on a link and save it on database( using jsp)  Hi Friend, Try the following code: 1)click.jsp var numberOfClicks = 0; function hello(){ numberOfClicks
jsp code
jsp code  how to display date in drop down list by jsp thus the date start from current date and for next year it has to check leap year function to february then it display 30 for some months else 31 for other months
jsp code - JSP-Servlet
jsp code  Can anyone help me in writing jsp/servlet code to retrieve files and display in the browser from a given directory.  Hi Friend, Try the following code: Thanks
jsp code - JSP-Servlet
jsp code  sample code for change password example Old Password: new Password: confirm Password
JSP code - JSP-Servlet
me how to link these pages with each other using JSP..and how to write the code using JSP.. requriment for Newuser: 1>fname,lastname 2>Loginname...JSP code  hello,i working in project with JSP technology,i have one
jsp code plz
;Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/jsp/popup-window-using-ajax-in-jsp.shtml The above links...jsp code plz  write jsp code which takes student roll number as input
code in jsp
code in jsp  hi.. I had started a project on college admission system in which two operators has been introduced one is admin who can view all... want a code to sort a list of students on the basis of there 12% marks and AIEEE
Disable of Combo - JSP-Servlet
details with source code and specify the technology you have used like Jsp/Servlet...Disable of Combo  Hi! Thanks for your fast reply. In my project i.... That means every user can give grade only at once... so i would like to disable
code for jsp to db connection using jdbc
code for jsp to db connection using jdbc  please send me the code   Hi Friend, Try the following code: 1)form.html: <html> <form method="post" action="http://localhost:8080/examples/jsp/insert.jsp"> <
jsp code - JSP-Servlet
jsp code  how to write a code in jsp with out using servelts finding sum and avg of 40 numbers  Hi Friend, Try the following code: Thanks  Hi Friend, Do one change in the provided code.As we
jsp code - JSP-Servlet
jsp code  sample code to create hyperlink within hyperlink example: reservation: train: A/C department non A/c Department
Jsp code for disabling record.
Jsp code for disabling record.  I want a Jsp and servlet code for the mentioned scenario. Q. A cross sign appears in front of each record, click to disable the record.System marks the record as disabled.The record
JSP Code - JSP-Servlet
, Please visit the following links: http://www.roseindia.net/jsp/data-grid.shtml http://www.roseindia.net/jsp/paging.shtml Thanks...JSP Code  Hi, Do we have a datagrid equivalent concept in JSP
 

 

 

DMCA.com