How to write JavaSctipt in Jsp
Hi all,
I am new to JavaSctipt. Just confused when to write JavaScripts inside Scriptlets and when not to write inside sctiptlets. Also wanted to know diffrence between client side scripting and server side scripting.
You don't write Javascripts inside scriptlets, you write it at the same scope as the html code.
Client side scripting (javascript) can be disabled by the client, and it cannot access any database for creating dynamic data, its usually used to handle browser events, like detecting mouseover events to bring up a popup etc. whereas server side scripting are more widely used for web apps, things like ebay, amazon and others.
Similar Messages
-
How can write string in jsp on beans..
Hello.
My English ability very poor sorry....
I am developing jsp using beans..
I want to see value on beans....
but I can't see....
I want to check my values...
plz help me....
how can I view my String , int... on the beans....Write a "getter" method for each variable you want to be able to read in the JSP.
example:
public class yourBean
// ... some code, contructor, etc...
private String yourVariable;
public void setYourVariable(String s)
yourVariable = s ;
public String getYourVariable()
return yourVariable ;
You can retrieve the value in your jsp with any of these ways:
1) use the <jsp:getProperty> tag
2) <%= yourBean.getYourVariable() %>
3) <% String s = yourBean.getYourVariable() %>
} -
How to write to a log file within a JSP
Hello everybody,
do you know how to write to a log file within a JSP.
my code is (/space/SP/tlf/ExcepcionJava.jsp):
<html>
<body bgColor=#C4E1FF>
<%@ page import="java.io.*" %>
<%
FileWriter salida = new FileWriter(response.encodeURL("log.txt"));
salida.write(request.getParameter("errorMsg"));
salida.close();
%>
</body>
</html>.. I run under Solaris, Jrun 2.3.3
I have also test with getServletContext().getRealPath(), but I get /netsrv/nes/docs/ instead of /space/SP/tlf/Hi,
Give the full path of the log file to the FileWriter. Such as;
FileWriter salida = new FileWriter(response.encodeURL("/usr/local/tomcat/logs/testlogs/log.txt"));
nurettin -
Dunno how to write JSP for login in......
Can someone help mi on write JSP coding for login in page?i dun really know how how to write JSP coding. i m now doing a project on Private Driving instructor portal where people can register as trainee or instructor.now i want to write the JSP coding on the login page part.... when instuctor login it will go to a instructor's main page n if a trainee login it will go to a trainee's main page.Can someone help mi on this??? it's very urgent n important for mi.Please help mi.
The easiest method I have found is to use a database to store the users details along with a flag indicating whether they are a trainee or an instructor. Upon logging in, you can use a bean to connect to the database and retrieve these values, then it is a simple matter of a jsp:forward tag to re-direct to the applicable page for trainee or instructor ...
e.g.
<pre>
***JSP PAGE ***
<%@page language="java" buffer="32kb" import="jspclasses.customer.*" errorPage="./error.jsp"%>
<jsp:useBean id="userBean" class="jspclasses.userInfoBean" scope="session"/>
* Get user and pass from form variables. (if passed)*
String user = request.getParameter("username");
String pass = request.getParameter("password");
* Retrieve fullname from session object. (if exists)*
fullname = (String)session.getValue("fullname");
String fwdPage = (String)session.getValue("fwdPage");
if (fullname==null) {
try {
* If no session has been established then attempt to create one using *
* the values passed through via form. If no values have been passed *
* through then variables will equal null as opposed to empty strings. *
* If null is evident, catch with NullPointerException. *
if (user.equals("") || pass.equals("")) {
fullname = "Not";
} else {
* Send values to method which validates users *
userBean.setUserInfo(user,pass);
* If an error was encountered within userBean the error *
* instance variable will != null. *
if (userBean.error == "") {
fullname = userBean.getFullname();
} else {
* Error was encountered so we set fullname to "Not", if *
* user was entered we re-display value and we instantiate *
* error variable to error value of userBean. *
fullname = "Not";
if (user!=null) uservalue=user;
error = userBean.error;
//out.println("Error is not null:<br>"+error+"<br>");
if (fullname!="Not") {
session = request.getSession(true);
session.putValue("fullname",fullname);
session.putValue("email",user);
session.putValue("user_id",userBean.getUserId());
session.putValue("user_type",userBean.getUserType());
session.putValue("sessionid",session.getId());
session.setMaxInactiveInterval(12000);
***END JSP***
*** START BEAN ***
public void setUserInfo(String user, String pass) {
String stmtString = "";
ResultSet rs = null;
// Check to see if a valid connection is available
getConnection();
// If getConnection returns null then
// connection successfully established
if (error.equals("")) {
try {
// Create SQL string to be sent to database
stmtString = "select * from serv_user where email = '" + user + "' and password = '" + pass + "'";
// Execute SQL
rs = stmt.executeQuery(stmtString);
// Specify estimated rows to be returned
rs.setFetchSize(1);
// If a row is returned get first and last name
if (rs.next()) {
user_id = ((rs.getString("USER_ID")!=null)?rs.getString("USER_ID"):"");
("USER_TYPE_ID"):"");
first_name = ((rs.getString("FIRST_NAME")!=null)?rs.getString("FIRST_NAME"):"");
last_name = ((rs.getString("LAST_NAME")!=null)?rs.getString("LAST_NAME"):"");
business = ((rs.getString("BUSINESS_NAME")!=null)?rs.getString("BUSINESS_NAME"):"");
address = ((rs.getString("ADDRESS")!=null)?rs.getString("ADDRESS"):"");
suburb = ((rs.getString("SUBURB")!=null)?rs.getString("SUBURB"):"");
state = ((rs.getString("STATE")!=null)?rs.getString("STATE"):"");
postcode = ((rs.getString("POSTCODE")!=null)?rs.getString("POSTCODE"):"");
hom_phone = ((rs.getString("HOM_PHONE")!=null)?rs.getString("HOM_PHONE"):"");
bus_phone = ((rs.getString("BUS_PHONE")!=null)?rs.getString("BUS_PHONE"):"");
mob_phone = ((rs.getString("MOB_PHONE")!=null)?rs.getString("MOB_PHONE"):"");
fax = ((rs.getString("FAX")!=null)?rs.getString("FAX"):"");
email = ((rs.getString("EMAIL")!=null)?rs.getString("EMAIL"):"");
pass_hint = ((rs.getString("PASSWORD_HINT")!=null)?rs.getString("PASSWORD_HINT"):"");
else {
error = "User <b>"+user+"</b> does not exist with specified password.<br>Please try again.";
} // END : ResultSet = true
} // END : TRY
catch (SQLException sqle) {
error = "<b>Error accessing database:</b><br> "+sqle.toString()+" - ORA:"+sqle.getErrorCode();
catch (Exception e) {
error = "<b>Error occurred in method setUserInfo()</b><br> "+e.getMessage();
} // END : CATCH
finally{
closeConnection();
try{
rs.close();
}catch(SQLException sqle){
} // END : IF
} // END : METHOD
} // END : BEAN
***END BEAN*** -
How to write jsp select record from Oracle divide per page , about 50 reco
Dear Expert,
How to write jsp select record from Oracle divide per page , about 50 record per page.
Thank you very much.I wish I could, but there is no single sign on module available for Fusion, also, so called Fusion is yet another Word With Big Letters, behind it there is yet another OC4J ( now Oracle switched to Weblogic though) container with bunsh of Oracle apps residing in it.
Generally speaking, neither Fusion nor Oracle Apps user database does not have any single authentication module available out of the box to integrate user database.
It's a long sad story running straight from Oracle Apps 11.0.5.
That's why I've created JAAS single sign on login module and used it ever since at OC4J 10.2 and onwards at OC4J 10.3
Back to the topic: to develop Apps and test them externally using the session bean I've isted above, one need to copy certain libraries from Oracle Apps server, then add them as libraries for JDeveloper project.
Here is the complete list:
oracle.apps.fnd.cache
oracle.apps.fnd.cache
oracle.apps.fnd.common
oracle.apps.fnd.functionSecurity
oracle.apps.fnd.metadata
oracle.apps.fnd.security
oracle.apps.fnd.util
oracle.apps.jtf.cache
oracle.apps.jtf.security
Edited by: Faceless on Nov 26, 2009 3:04 AM -
How to write this java code in jsp using jstl tags?
Can anybody help me on this?
I dont know how to check the containsKey using jstl tags?
<%
LinkedHashMap yearMap = (LinkedHashMap)request.getAttribute("yearMap");
TreeSet nocSet = (TreeSet)request.getAttribute("nocSet");
Iterator yearMapIt = yearMap.keySet().iterator();
while(yearMapIt.hasNext())
int yearValue = (Integer)yearMapIt.next();
%>
<tr>
<td><%=yearValue%></td>
<%
LinkedHashMap monthMap = (LinkedHashMap)yearMap.get(yearValue);
Iterator nocSetIt = nocSet.iterator();
while(nocSetIt.hasNext())
String nCase=(String)nocSetIt.next();
if(monthMap.containsKey(nCase))
String count = (String)monthMap.get(nCase);
%>
<td> <%= count %> </td>
<% }
else
%>
<td> 0 </td>
<%
%>
</tr>
<% } %>Edited by: avn_venki on Feb 18, 2008 11:54 PM<c:forEach var="yearMap" items="${requestScope.yearMap}">
<th> <c:out value="${yearMap.key}"/> </th>
<bean:define id="monthMap" value="${yearMap.value}"/>
<c:forEach var="nocSet" items="${nocSet}">
then how to write containsKey using tags?? -
How can we write methods in Jsp ?
I want to write methods in jsp in such a way that in one method I should have "Creating database connection" and in another method I want to create ResultSet and in another method I want to access the ResultSet.
u can write methods in jsp using the following tag
<%!
public void myMethod()
%> -
How to write a java function for use in where clause in SQL statement
Hi,
Does anyone know a good tutorial on how to write and include a Java class/function into Oracle.
I'd like to write mathematical function to use in my queries, but the resources available in PL/SQL are very limited.
Many thanxPim,
I see you got an answer in the PL/SQL forum.
But in case you haven't seen it, perhaps this Web page will help:
http://www.oracle.com/technology/tech/java/jsp/index.html
Good Luck,
Avi. -
How to display PDF in JSP using Iframe
Hi All,
I am using Struts 2. I am building my file in ActionClass with seperate Method like getGeneratedPDF() in which, I am setting header of response and writing into PDF.
This method will be called from JSP by this way
s:property value="getGeneratedPDF()" />
But It displayed Junk Characters , and this PDF is not static (already Generated). It is generated and build on Fly.
I have 2 questions 1 -- How to display PDF in JSP in proper way without Junk Character in it?
questions 2 -- How to display it in Iframe?
Please help me , If you know the solution.
Thanks in Advance,
Jimmyjamy_26 wrote:
But It displayed Junk Characters , and this PDF is not static (already Generated). It is generated and build on Fly.A PDF file is a binary file, not a text file, and you're trying to display it as String. Of course you would get "junk characters". Have you ever tried opening a binary file (pdf, doc, jpg, xls, etc) using a text editor like Notepad?
I have 2 questions 1 -- How to display PDF in JSP in proper way without Junk Character in it?Display it as binary stream, not as text stream. You can display it standalone, just let the link/form/addressbar URL point to some Servlet which writes the InputStream of the PDF file to the OutputStream of the response, along with a correct set of response headers (at least content-type, content-disposition and content-length), so that the browser can open it in the correct application (which is usually Acrobat Reader). If you want to embed the PDF file in a JSP, then one of the ways is indeed using the HTML <iframe> tag.
questions 2 -- How to display it in Iframe? Just let the iframe URL point to the aforementioned Servlet.
You can find here an example of a generic file servlet, you may find it useful to get the idea how to do it: [http://balusc.blogspot.com/2007/07/fileservlet.html]. -
How to write sync service in sybase unwired platform
Hi
How to write sync service in sybase unwired platform?
Thanks in advance....Hi!
A RESTful web service (also called a RESTful web API) is a simple web service implemented using HTTP and the principles of REST. It is a collection of resources, with three defined aspects:
- the base URI for the web service, such as http://example.com/resources/
- the Internet media type of the data supported by the web service. This is often JSON, XML or YAML but can be any other valid Internet media type.
- the set of operations supported by the web service using HTTP methods (e.g., POST, GET, PUT or DELETE).
On Sybase Unwired WorkSpace you can select, in Enterprise Explorer, REST Web Services connection defining a resource base URL and URI template, and then using this as MBO defining HTTP method and parameters.
Try this:
http://en.wikipedia.org/wiki/Representational_State_Transfer
and this:
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01283.0155/doc/html/fre1261416769728.html
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc01283.0155/doc/html/fre1261424660910.html -
How to use threads in JSP???
hello
i want to use threads with JSP.
i want to write a jsp page which will
start 2 different threads. the 1st thread should just display a message and the second page should redirect this page to another jsp page.
till the redirection is goin on, the message should be displayed in the browser from the 1st thread.
i dont know actually how to use threads in JSP by implementing the Runnable insterface, if not m then how do i do it ??
thanx
Kamal JaiWhy do you want to use threads to do this ??
If you write a message and do a redirection, the message will be displayed until the other page will be loaded into the browser...
I already launched a thread from a JSP but it was for a four hour process where the user can close his browser windows. -
How to use datagrid in jsp ?
Hi All ,
Can any body let me know , how to use datagrid in jsp pages .I have downloaded the taglibs-datagrid.jar file and taglibs-datagrid.tld. I have saved the .jar File in the WEB-INF/lib and .tld to the WEB-INF directories.
I wrote a program that is getting a collection from the request and i just want to display the objects in the datagrid.Please help me out of this problem.It's better to explain with example. Waiting for a response.
Regards,
RakeshWhy do you want to use threads to do this ??
If you write a message and do a redirection, the message will be displayed until the other page will be loaded into the browser...
I already launched a thread from a JSP but it was for a four hour process where the user can close his browser windows. -
How to call script in jsp
3A-_@. Feb 8, 2007 3:08 AM
Hi,
I have abc.jsp file where i want to call javascript on pressing submit button.
<input type="text" name="UserName" value="" width="30" />
<input type="submit" value="Submit" onclick=" <what should i write here??">
here how to call script?
and in the same abc.jsp file i have javascript ( i am not sure about the way i m accessing text value inside javascript is right or not)
<SCRIPT LANGUAGE="javascript" >
here how can i access UserName field value here??
if(isThisNotNull(UserName))
alert("UserName Is Mandatory");
</SCRIPT>If you do it like Greeks says then the javascript variable will be set when the page loads (userName probably blank). You will want the current value from the input field so use getElementById().
Edited by: gmachamer on Nov 21, 2007 7:23 AM
oops, just noticed Greeks posted both replies... so what I should have said is use his first suggestion as the second is not what you want. -
How to run exception using JSP?
How to run exception using JSP?
Why would you need the <%%> between the if else blocks? Even if you attempt to write some data within the blocks in java, you will still get an error. For example, this is illegal:
if(done)
System.out.println(true);
System.out.println("Hello World");
else
System.out.println(false);
}The compiler is expecting the 'else' to be directly after the body of the if. If it encounters anything else, it will complain. So you cannot do this in jsp either, regardless if it's a different technology, it's the same compiler. -
How to write chart application using netcharts.server.api ?
Hi to all.
i need to write a chart application in Java, which makes use of netcharts.server.api.
Iam having only jar files. Which are netcharts.jar, chartworks.jar, commons-httpclient.jar, commons-logging.jar and ncstoolkit.jar in my hand.
I need to make use of above jars only to build line graph or charts or any thing.
That application has to work in html or jsp or servlets, if possible in swings.
can any buddy please help me in this regard and guide me.
I am very much thank full for any reply.
please help me.
Thanks in advance.Hi su,
Thanks for your reply.
can you tell me in detail where you have used those jar files and how?
Comming to my basic application,
iam in the way to find first basic application using netcharts.server.api package.
I came to know many things.
I found the how to build application in JSP's
But when iam executing that, it is throwing error like
{color:#ff6600}netcharts.server.api.NSToolKitException: java.net.ConnectException: Connection refused: connect{color}
at the time of calling
{color:#ff6600}String thechart = toolKit.getChartAsImageAndMap(
"/CDXExamples/barxDATAvariable.cdx";,
chartParams,
request,
true);
{color}at first i have created
{color:#ff6600}NSWebToolKit toolKit = new NSWebToolKit("Examples");{color}
toolkit object with out errors.
But in other reference i found the code like
{color:#ff6600}NSWebToolKit toolKit = new NSWebToolKit(NETCHARTS_SERVERNAME, 8001,"MyFirstProject");{color}
Here it is saying
replacing {color:#ff6600}NETCHARTS_SERVERNAME{color} with the machine name where NetCharts Server is installed:
Iam getting doubt, is it necessary to install netcharts server to make use of netcharts.server.api classes?.
can any buddy please help me in this regard.
Thanks in advance.
Maybe you are looking for
-
Linking fields between comm_pr_frg_rel and Z4000000000001
Hi , Can anyone guid me to get the relationship between Catalog based Attribute and Product ( Product - Set - Assignment "comm_pr_frg_rel" and "Z4000000000001"). Venki.
-
I´m a frequent user of personalized tags on my contacts. When I update to iOS7.0.2, my tags don't appear on alphabetical order as they were on the other system. I already made a restoration of the system and it didn't work. Is there any way to fix t
-
ITunes top songs differnet on hope page than when you go to it
On iTunes store's home page it shows these songs but when I click on the little arrow pointing to the right to see the full list of songs, it has a completely different list. See, So anyway is there a way to report the error because when I clicked on
-
How to install java plugin in BB Curve 9360
Hi I am not able to view the oracle e business suite page. It is asking me to install the java plugin oaj2se.exe to my BB Curve 9360. Any suggestions pls
-
Hello Experts- I have a query that mergers data from server1(2008r2) with server2(2012) and updates some data. It uses two different databases in both server, I used to run this manually whenever requested by importing the tables to the 2012 server t