i've written the javascript code inside
myjsp.jsp
<%
try {
String id=request.getParameter("id");
%>
<script type="text/javascript" >
alert("TRY"+ <%=id %>);
document.getElementById("mytext").readonly="readonly";
</script>
<%
} catch (Exception e) {
%>
<script type="text/javascript" >
alert("CATCH"+<%=e%>);
</script>
<%
}
%>
So, whenever value will be passed into the id it'll show the value of id into the alertbox and also it'll make the textbox whose id is mytext will become disable.
So, when i'm executing the myjsp.jsp page without passing the parameter it shows the output as TRYnull, but when i'm passing the value into id then it's not showing anything, not even alertbox. Any idea !!
My jsp page
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<%
try {
String id=request.getParameter("id");
%>
<script type="text/javascript" >
alert("TRY"+ "<%=id %>");
alert(document.getElementById("mytext"));
</script>
<%
} catch (Exception e) {
%>
<script type="text/javascript" >
alert("CATCH"+<%=e%>);
</script>
<%
}
%>
<input id="mytext" name="mytext" />
</body>
</html>