call from java

call from java

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
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
Advertisements
call dll from java - JSP-Servlet
call dll from java  Hello all how to call dll file methods in java
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
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
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
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
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
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
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
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
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 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
Call the parent page(uses master page) from the child page
Call the parent page(uses master page) from the child page  how to call the parent page from child without refreshing the parent and my parent window uses the master page
Call the parent page(uses master page) from the child page
Call the parent page(uses master page) from the child page  how to call the parent page from child without refreshing the parent and my parent window uses the master page
how to call servlet from html page at anchor tag ?
how to call servlet from html page at anchor tag ?  I have a very different problem as i am using netbeans ide 6.9 ml to make a website in java and my website is running on it but after uploading it on server
How to call jasper from jsp or servlet - JSP-Servlet
How to call jasper from jsp or servlet  Hi Expert , I created jasper report using ireport.how to call that jasper with jsp file or servlet file ? Thanks in advance Eswaramoorthy.s
how to call the array variable in scriptlet from javascript function
how to call the array variable in scriptlet from javascript function  This is the scriptlet code:- <% String[] abc={"saab","volvo","bmw","Benz","Porsche","Jaguar"}; %> Actually i want the array variable one by one
error got minus one from read call - JSP-Servlet
minus one from a read call oracle.jdbc.dbaccess.DBError.throwSqlException...error got minus one from read call  hiiii while connecting my servlet...) the code is as follows: // *DataBase Connectivity from the Servlet. import
how to open one Jframe from main method call
how to open one Jframe from main method call  I have downloaded a snake game project in java. Initially the project contains three java files i.e...", Rules.java Now this project having five java classes in this project- Engine.java
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
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
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
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
remote procedure call using java - JSP-Servlet
remote procedure call using java  what is the romote procedure call and related coding in java?  Hi Friend, The RPC (Remote Procedure Call) is a mechanism that enables a remote procedure call from a client
how to call a java class in jsp - JSP-Servlet
how to call a java class in jsp  hi.. friends iam new to roseindia.i found it very nice site to clarify our douts. i have a problem to use my java class in a jsp.can anyone please help me with this query
how to call a java class in jsp - JSP-Servlet
how to call a java class in jsp  hi.. friends iam new to roseindia.i found it very nice site to clarify our douts. i have a problem to use my java class in a jsp.can anyone please help me with this query
how to call the parent page from child without refreshing the parent and my parent window uses the master page
how to call the parent page from child without refreshing the parent and my parent window uses the master page   how to call the parent page from child without refreshing the parent and my parent window uses the master page
how to call the parent page from child without refreshing the parent and my parent window uses the master page
how to call the parent page from child without refreshing the parent and my parent window uses the master page   how to call the parent page from child without refreshing the parent and my parent window uses the master page
how to call the parent page from child without refreshing the parent and my parent window uses the master page
how to call the parent page from child without refreshing the parent and my parent window uses the master page   how to call the parent page from child without refreshing the parent and my parent window uses the master page
how do i make a phone call from my app without quitting my application
how do i make a phone call from my app without quitting my application  hi, I am working on creating a call application, i am making a call from my... quits , i want my application to go to background and resume on call end ...please
how to call java script function through java class file
how to call java script function through java class file  how to call jframe in java script
conference call
conference call  hi am a java beginner I want to develop a simple conference call system over a LAN can u please enlighten me on the basics that I have to do and kno first
conference call
conference call  hi am a java beginner I want to develop a simple conference call system over a LAN can u please enlighten me on the basics that I have to do and kno first
conference call
conference call  hi am a java beginner I want to develop a simple conference call system over a LAN can u please enlighten me on the basics that I have to do and kno first
conference call
conference call  hi am a java beginner I want to develop a simple conference call system over a LAN can u please enlighten me on the basics that I have to do and kno first

Ads