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



Home Answers Viewqa JavaMail call from java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Narendra
call from java
3 Answer(s)      6 years and 6 months ago
Posted in : JavaMail



Advertisement
View Answers

July 31, 2008 at 2:52 PM


Hi Narendra,

You can use the java.net package to call a servlet from the java code.

java.net.HttpURLConnection;
java.net.URL;


Thanks
Manas


July 31, 2008 at 6:36 PM


Hi friend,

package javacode;

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

public class ServletExample extends HttpServlet {
protected void service(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html;charset=UTF-8");
PrintWriter out = res.getWriter();
printPageStart(out);
//Obtain the session object, create a new session if doesn't exist

HttpSession session = req.getSession(true);
Integer param = (Integer) session.getAttribute("MySessionVariable");
if (param != null) {
session.setAttribute("MySessionVariable", new Integer(param.intValue() + 1));
param = (Integer) session.getAttribute("MySessionVariable");
}
else{
param = new Integer(1);
session.setAttribute("MySessionVariable", param);
}
out.println("You have displayed this page <b>" + param.intValue() + "</b> times this session.<br/><br/>");
out.println("Hit the browsers refresh button.");
printPageEnd(out);
}
private void printPageStart(PrintWriter out) {
out.println("<html>");
out.println("<head>");
out.println("<title>Store and retrive session variable</title>");
out.println("</head>");
out.println("<body>");
}

private void printPageEnd(PrintWriter out) {
out.println("</body>");
out.println("</html>");
out.close();
}
}

-------------------------------------------


July 31, 2008 at 6:41 PM



<?xml version="1.0" encoding="ISO-8859-1"?>



<web-app xmlns="http://java.sun.com/xml/ns/javaee";

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";

version="2.5">



<description>

Servlet and JSP Examples.

</description>

<display-name>Servlet and JSP Examples</display-name>
<servlet>
<servlet-name>servletexample</servlet-name>
<servlet-class>javacode.ServletExample</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>servletexample</servlet-name>
<url-pattern>/jsp/ServletExample</url-pattern>
</servlet-mapping>


</web-app>


-----------------------------------------------

Read for more information.

http://www.roseindia.net/servlets/

Thanks.


Related Tutorials/Questions & Answers:
call from java - JavaMail
call from java  Hi, how i will call servlet from java.. plz its urgent.. Thanks Narendra  Hi Narendra, You can use the java.net package to call a servlet from the java code
call dll from java - JSP-Servlet
call dll from java  Hello all how to call dll file methods in java
Advertisements
cant call cmd from java - Java Beginners
cant call cmd from java   How can I call this from java to be executed by cmd ? ConvertXLS.EXE /S "C:\Extracto\*.CSV"/T "C:\Extracto\*.XLS" /C-4143 /F6 /M2 /R /V
Call dll from java - JSP-Servlet
Call dll from java  Any one tell me how to call dll from java. Basically , i want read the cash m/c parameters(4,i.e i want to read the cash count) in java .For this i want to call a dll from java . Also any one have
how to call from pc to telephone in java - MobileApplications
how to call from pc to telephone in java  Hi, presently I am working on "make a call from pc to telephone" in java. I am unable to procceed how to start. I am new this technoloy.Please give me some valuable suggestions how
how to call an exe file from java - Java Beginners
how to call an exe file from java  hi, how to call exe file with some parameters from java and save the output of the exe file in a specified path. Please let me know immediately..its urgent!!! Thanks in advance
Diff ways to call a EJB from Servlet, JSP - Java Interview Questions
Diff ways to call a EJB from Servlet, JSP  How can I call EJB from Servlet or JSP
How I call the function union from the main - Java Interview Questions
How I call the function union from the main  Please, from public static void main(String[] args) I would like to call the function union and I...}, }; //calling the function union : paramtere to pass is mat //how i call
how to call jsp from flex
how to call jsp from flex  hi, i want to know that how can i call a FLEX from JSP. . A good Example will be appreciated
iPhone Make Call from App
iPhone Make Call from App  iPhone Make Call Programmatically I have created an application in iPhone that has the functionality to make Call from App. I am just wondering how to make a call programmatically... is there any
how to call jsp from flex
how to call jsp from flex  Plz help me out to get JSP from FLEX.... I need your help.... Thanks for future
database call from javaScript - Ajax
database call from javaScript  Dear All, In my project i have one... name. and i have to do this in javascript.How do i call database query ,if suppose i have selected two building from text area,i have to finish
Call an array from multiple functions
Call an array from multiple functions  I am having two methods in this method i am getting array values from another class. i create same array name for accessing the method values(array) but it will access only one method values
How to call business deleget class(EJB) from JSF Page? - Java Server Faces Questions
How to call business deleget class(EJB) from JSF Page?  Hi, How to call a biz i.e. business deleget class(EJB) from JSF Page? I am creating one 3-tier banking application. I am using JSF 1.2 I want to know that.How to call
how to call javascript function from flex
how to call javascript function from flex  how to call javascript function from flex
Call Picture into java
Call Picture into java  Morning sir, I want to view my picture(longblob) from My DB Mysql, I have a code like this. try { Class.forName... res = stat.executeQuery("select * from karyawan_ft where nik
Call Picture into java
Call Picture into java  Morning sir, I want to view my picture(longblob) from My DB Mysql, I have a code like this. try { Class.forName... res = stat.executeQuery("select * from karyawan_ft where nik
call frame - Java Beginners
call frame   dear java, I want to ask something about call frame...(browse) then view FrameB. In FrameB i fill JTextfield1(FrameB) with "JAVA... it because after i fill JTextfield1(FrameB) with "JAVA" then click button(FrameB
How to make phone call from web application
How to make phone call from web application  I'm creating an XHTML application, which can be viewed via IPhone or Blackberry. Application needs to make call to a specific number when user clicks a particular button. Please
Java-call by value - Java Beginners
Java-call by value  Why java is called strictly "call by value" and not "call by reference" ?Please explain with example?  Hi Friend, The Java programming language does not pass objects by reference; it passes
java call by reference - Java Beginners
java call by reference  in java do we have ane term like call... affect the caller?s original variables. Java never uses call by reference. Java... you call a method by reference, the callee sees the caller?s original variables
How to call the run method from another class?
How to call the run method from another class?  Sorry, if this is a stupid question. I would like to find out how to call the run method... want to call this from AdaugaComanda.java, so that changes can be seen
Unable to call .jrxml file from jsp
Unable to call .jrxml file from jsp  Hi, I am doing web application... plugin. After creating report in netbean when i call that jrxml file...()) { rsOfIncident =db1.getExecute("Select * from Incident
getting null value in action from ajax call
getting null value in action from ajax call  Getting null value from ajax call in action (FirstList.java)... first list is loading correctly. Need... language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding
getting null value in action from ajax call
getting null value in action from ajax call  Getting null value from ajax call in action (FirstList.java)... first list is loading correctly. Need... language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding
getting null value in action from ajax call
getting null value in action from ajax call  Getting null value from ajax call in action (FirstList.java)... first list is loading correctly. Need... language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding
Call servlet from javascript - JSP-Servlet
Call servlet from javascript  Hi in my application i have jsp that designs view, javascript for validation and servlet that perform business logic... screen when the user clicks submit button i have to pass this column values from
call frame again - Java Beginners
read from jbutton1 in FrameA to FrameB,then i write "JAVA" in Jtextfield1(FrameB),then i click jbutton1 in FrameB. "JAVA" is a word i'am write in Jtexfield1...call frame again  d, thank's for your answer, but i can't combine
function call in javascript - Java Beginners
function call in javascript  hi all, i've written a javascript , but i m unable to call a function getExpression.i dont know why getExpression function is not being called. heres my code : function
How to call java method on Button click in jsp?
How to call java method on Button click in jsp?  How to call java method on Button click in jsp
call a function - Java Interview Questions
call a function  Please i want to call the function union via main How I can do it??? Here you find my code With my best Regards... call it } }   Hi Friend, Please post your problem
 

 

 

DMCA.com