Showing posts with label tgmc. Show all posts
Showing posts with label tgmc. Show all posts

Wednesday, March 20, 2013

comment_icon 0 Handling Session in JSP

In this Tutorial we are going to see that how can we Handle SESSION in JSP.


1. Setting Session : 

Before we validate or check the existing session it is important to know that how we set session in JSP. 
we use session.setAttribute("ATTRIBUTE NAME","ATTRIBUTE VALUE"); you can set as many attribute as you want.

2. Retrieving valuse from session attribute

To retrieve value from session attribute we use  following method. session.getAttribute("attribute name");
to store the retrieved value in a variable we write code as shown below.
 data-type variable-name=(data type cast)session.getAttribute("attribute name");
e.g.  String  signin=(String)session.getAttribute("username");

3. Ending or Invalidating session.

To End the current session and all attributes value we use session.invalidate(); method.

4. To Prevent user from going back to the previous page after logout put following META-TAG in every page's Header

<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> 


working Example 

 1. index.jsp


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
 language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
 <html>
<head>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> 
<title>index</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<% String  signin=(String)session.getAttribute("username");
 
 if(signin==null) { 
/** perform some your own logic for not signed in user , i'm just forwarding to login page
 **/
  %> <a href="login.jsp">click to login</a>
 <%
 }
 else {
 
 /** logic for logges in users **/
  %>

<h3>successfull login</h3>
  <a href="logout.jsp">click to logout</a>
  <%} %>
</body>
</html>

2. Login.jsp


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
 language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<html>
<head>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> 
<title>login</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<%
/** setting username here . you  will do it after processing login code **/
 session.setAttribute("username","your user's username");
 %>
 i set the session, now click on index page link to verify it
 <a href="index.jsp">go to index page</a>
</body>
</html>

3. Logout.jsp

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><%@page
 language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<html>
<head>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> 
<title>logout</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<% //session.setAttribute("username",null);
 session.invalidate();
 %> 
 <jsp:forward page="index.jsp"/>

</body>
</html>

Wednesday, March 13, 2013

comment_icon 2 File Download Script For JSP

In this Tutorial  i'm going to explain how you can serve files to your users using JSP. Since we are not serving a HTML page so first we need to tell the browser that what kind of data we are going to serve for that we set Response Headers
 response.setContentType("application/msword");
 response.addHeader( "Content-Disposition","attachment; filename=your file name" );
Here application/msword is the mime type you can search internet for diff. mime type required for  diff. extensions few commonly used are
  • image/jpeg
  • text/plain
  • application/pdf

link format for filedownload

<a href="download.jsp?filename=myresume.doc">Download my resume</a>

Download.jsp


<%@ page  import="java.io.FileInputStream" %>
<%@ page  import="java.io.BufferedInputStream"  %>
<%@ page  import="java.io.File"  %>
<%@ page import="java.io.IOException" %>


<%

   // you  can get your base and parent from the database
   String base="file";
   
   String filename=request.getParameter("filename");
// you can  write http://localhost
   String filepath="http://localhost:8080/filedownload/"+base+"/";

BufferedInputStream buf=null;
   ServletOutputStream myOut=null;

try{

myOut = response.getOutputStream( );
     File myfile = new File(filepath+filename);
     
     //set response headers
     response.setContentType("application/msword");
     
     response.addHeader(
        "Content-Disposition","attachment; filename="+filename );

     response.setContentLength( (int) myfile.length( ) );
     
     FileInputStream input = new FileInputStream(myfile);
     buf = new BufferedInputStream(input);
     int readBytes = 0;

     //read from the file; write to the ServletOutputStream
     while((readBytes = buf.read( )) != -1)
       myOut.write(readBytes);

} catch (IOException ioe){
     
        throw new ServletException(ioe.getMessage( ));
         
     } finally {
         
     //close the input/output streams
         if (myOut != null)
             myOut.close( );
          if (buf != null)
          buf.close( );
         
     }

   
   
%>

Project Structure


Download zip

Sunday, November 4, 2012

comment_icon 0 Boosting up your COMPUTER STARTUP

Iyour computer or Laptop takes time during start-up after you installed few heavy softwares ? Don't worry there is way you can decrease your computer start-up time .before we go down lets understand how it works.
Whenever you install software like oracle,DB2,SQLServer,Apache etc. they will install there services which will be started every time you turn on your pc,like when you install oracle it will add few services given below.

OracleDBConsoleorcl
OracleOraDb10g_home1TNSListener
OracleServiceORCL

so what we gonna do then because these services are essential to use the products ? so what we do is we disable these services to start on system boot  ,and whenever we need then we start them manually. But this will become hectic to type the command every time  so what we gonna do is we will make a batch file for this task .and when ever we need them we will make a single click.

Disabling services from getting started on system boot.

    1. click on start button
    2. type cmd right click and run as administrator
    3. Command Prompt will popup as shown.
    4. type net start all the service list is shown just note down the services name you want to disable and set the startup to manually .
    5. Now open Notepad
    6. for every service type following command  sc config service-name start= demand (note the space between = and demand)
    7. save file as set_servicemanual.bat (in file type select as all files)
    8. Run saved file as administrator
    9. for our example Notpad file looks like  
sc config OracleDBConsoleorcl start= demand
sc config OracleOraDb10g_home1TNSListener start= demand
sc config OracleServiceORCL start= demand 
pause

Creating the Batch file for manual starting services

    1. open notepad
    2. for every service type command as  net start "service name" 
    3. save file as start_servicemanual.bat (in file type select as all files)
    4. Run saved file as administrator
    5. for our example Notpad file looks like   
net start "OracleDBConsoleorcl"
net start "OracleOraDb10g_home1TNSListener"
net start "OracleServiceORCL"
pause


 

Friday, July 20, 2012

comment_icon 0 Getting Started with TGMC

If you doing the TGMC project then you have to use IBM  tools only
like
  1.  Rational Software Architect For  Unified modeling (UML ) and SRS 
  2. DB2 for Database
  3. Rational Application Developer or Eclipse (only open source not Commercial)
  4. WebSphere Application Server or WebSphere Community addition For Deployment 
But When you are Installing or using The Rational Application Developer (RAD)  in some cases it didn't get installed so What you can do for that ?



My Advice is that you  can for Eclipse it is available free 

but there are few things where you have to compromise i just list few of them
  1. No Drag N Drop : Eclipse did't provide pallete view 
  2. You have to use  WebSphere Community Edition server only 
these two are major compromises but eclipse works pretty well so you can go for it if you face any problem with RAD in installation .

So From Where you can download these Tools ?
This is the most Common Questions Regarding the TGMC
So i just give a brief on that
 IBM will provide their toolkit Disks but it will take time so better download them by own 
1st thing 1st so 1st in the list is
  • RSA(Rational Software Architect ) : you can download the trial version form the website they will give atleast 1 month which is enough for creating your SRS 
  • DB2 : its community edition is free and you can download it from ibm website
  • RAD/Eclipse : you have to download the trial version of RAD or you can use Eclipse which is free of charge
  • Server : for deployment and testing you need a server so you can go for  WebSphere Community addition because its free and works pretty well
  Download Links :

 Note: Before downloding Register yourself on IBM -Site (it s free) make suer you will download Installation manager . it will be available on same download page  .

Thursday, July 19, 2012

comment_icon 1 Project scenarios for TGMC 2012


Today i just seen the list of TGMC scenarios an i am quite surprised because this time  scenarios are  new and quite challenging . These  scenario's fit quite well in student's final year Academic projects.

if you are reading this blog and you are final year student then my only advice to you is go for the TGMC project as FINAL year Academic project because there your 40% work is already done what left is 60% and you will also become eligible for blue scholar if you  make TGMC project and get 2 IBM certifications .
you can do IBM-DB2, and Z-OS both are free for students jo just go for it .
all the best to all students


Friday, July 13, 2012

comment_icon 0 The Great Mind Challenge 2012 - Registrations Opened

One more pillar in TGMC's history . TGMC 2011 Completed and TGMC 2012 registrations opened.
TGMC provides  a  very good opportunity to the students who are studying in 3rd year or final year.
i started working for tgmc in 3rd year and my experience is that every computer science engineer should participate in TGMC. Congrats to TGMC 2011 winners and all the best for 2012's .click the  register button for registration of your team





For more details and regular updates on tutorial please follow us on Facebook


https://www.facebook.com/Tutorials-For-TGMC

Sunday, February 26, 2012

comment_icon 5 Sending E-Mail via G-mail using Java


package mymail;



import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class Mymail   {
 
 
 public Mymail(){
  super();
 }


/*REMOVE THIS TO TEST AS JAVA APPLICATION 

public static void main(String args[]) throws AddressException, MessagingException{
  Mymail m =new Mymail();
  m.GmailSend("coolasr@gmail.com", "hello", "hello");
 }*/


public boolean GmailSend  (String to,String subject,String messageText) throws AddressException, MessagingException{
  
String host="smtp.gmail.com", user="YOUE USERNAME", pass="YOUR PASSWORD";

      
String SSL_FACTORY ="javax.net.ssl.SSLSocketFactory";       
boolean sessionDebug = true;
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol.", "smtp");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.", "true");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.socketFactory.fallback", "false");
props.put("mail.smtp.socketFactory.class", SSL_FACTORY);
Session mailSession = Session.getDefaultInstance(props,null);
mailSession.setDebug(sessionDebug);
Message msg =new MimeMessage(mailSession);
//msg.setFrom(new InternetAddress(from));
 try
  {
   InternetAddress[] address = {new InternetAddress(to)};
 msg.setRecipients(Message.RecipientType.TO, address);
 msg.setSubject(subject);
 msg.setContent(messageText,"text/plain"); // use setText if you want to send text
 Transport transport = mailSession.getTransport("smtp");
 transport.connect(host, user, pass);
 transport.sendMessage(msg, msg.getAllRecipients());//WasEmailSent = true; // assume it was sent
 return true; 
      
 }
 catch(Exception err) {
      
 //WasEmailSent = false; // assume it's a fail
 return false; 
 //System.out.println("Error"+err.getMessage());
 }
         //transport.close();

 }
}














Friday, February 10, 2012

comment_icon 0 Uniform & Sexy forms with JQuery

wanna make your Forms Look attractive ? 



Have you ever wished you could style checkboxes, drop down menus, radio buttons, and file upload inputs? Ever wished you could control the look and feel of your form elements between all browsers?

If so, Uniform is your new best friend.

Uniform masks your standard form controls with custom themed controls. It works in sync with your real form elements to ensure accessibility and compatibility.

Uniform styles:

  • Selects (Drop downs)
  • Checkboxes
  • Radio buttons
  • File Upload inputs

Tested & Compatible in:

  • Safari 3+
  • Firefox 3+
  • IE7+
  • Chrome
  • jQuery 1.3+
  • Opera 10+
  • Degrades gracefully in IE6

Themes

Theming is central to the philosophy of Uniform. We don’t want you to feel limited to just using the default style. You can design your own theme with our theme kit and create most of the code you’ll need using our custom theme generator.
HomePage URL http://uniformjs.com



Friday, December 9, 2011

comment_icon 2 Download RSA ( Rational Software Architect ) - A tool for software Modeling

Download via IBM site

Download Via Torrent

Torrent Includes :

Files:13
Size: 5.35 GB (5741557433 Bytes)

IBM® Rational® Software Architect is an integrated analysis, design, and development toolset that supports the comprehension, design, management, and evolution of enterprise solutions and services. It includes design, analysis, and development capabilities for software architects and model-driven developers creating service-oriented architecture (SOA), J2EE, and portal applications.

This product offering includes:
1)Quick Start CD
2)Rational Software Architect
3)Rational Agent Controller
4)WebSphere® Portal test environments
5)Rational ClearCase® LT
6)Crystal Reports Server

7)Activation Kit for Rational Software Architect
8)Rational License Server
9)IBM Installation Manager
10(IBM Packaging Utility
11)WebSphere Application Server for Developers
12)CICS® Transaction Gateway

For more info
http://www-1.ibm.com/support/docview.wss?uid=swg24013690

comment_icon 173 Sending sms via way2sms using Java


This Page has been no more upadted please visit thie link for updated information How to send sms in java : onl9class.com

API NOT WORKING ANYMORE - INDYAROCKS MESSAGE NOT GETTING DELIVERED

i have a paid API
If you are willing to pay small amount such as 50-100RS for 100-300sms
contact me at abhirathore2006@gmail.com

The sole purpose of the Api is to be used in development by students.so i am not releasing the actual sour

UPDATED CODE
This Tutorial showz that how you can use the http://www.indyarocks.com/ for sending message using your java application
Steps to Follow

  1. create a account on http://www.indyarocks.com/ 
  2. after getting indiarocks username and password use the code given below.
  3. modify the following details
    1. put your email id in Email string
    2. put your indiarocks username
    3. put your indiarocks password
    4. put number as the number on which you want to send sms
    5. put your messgae in messgae string , i limited the length to 110 char for stopping the misuse
  4. if you copy the code in your application's jsp page don't forget to import java.net.*,java.io.*,java.net.URLEncoder

Sunday, December 4, 2011

comment_icon 0 Ajax From Scratch - a WORKING demo for Jquery-Ajax in jsp

This tutorial covers a working example of ajax in jsp
note: example is just same as i used in my previous tutorial so to setup thing use that tutorial :creating-simple-db2-database-Application




Saturday, December 3, 2011

comment_icon 0 Learning Resources for DB2 pure XML with samples


XForms and DB2 pureXML
Handle pureXML data in Java applications with pureQuery



pureXML Samples

The pureXML feature enables well-formed XML documents to be stored in their hierarchical format within columns of a table. XML columns are defined with the new XML data type. Because the pureXML feature is fully integrated into the DB2 database system, the stored XML data can be accessed and managed by leveraging DB2 functionality. This functionality includes administration support, application development support and efficient search and retrieval of XML via support for XQuery, SQL or a combination of SQL/XML functions.
There are various samples provided to demonstrate the XML support; these are broadly categorized as:
Administration samples
These samples demonstrate the following features:
  • XML schema support : Schema registration and validation of XML documents
  • XML data indexing support : Indexes on different node types of XML value
  • Utility support for XML : Import , export, runstats, db2look, and db2batch support for the XML data type
Application Development samples
These samples demonstrate the following features:
  • XML insert, update, and delete : Inserting XML values in XML typed columns, updating and deleting existing values
  • XML parsing, validation, and serialization support : Implicit and explicit parsing of compatible data types, validating an XML document, serializing XML data
  • Hybrid use of SQL and XQuery : Using SQL/XML functions like XMLTABLE, XMLQUERY and the XMLEXISTS predicate
  • XML data type support in SQL and external procedures: Passing XML data to SQL and external procedures by including parameters of data type XML
  • Annotated XML schema decomposition support : Decomposing an XML document based on annotated XML schemas
  • XML publishing functions : Using functions to construct XML values
XQuery samples
These samples demonstrate the use of axes, FLWOR expressions, and queries written with XQuery and SQL/XML.
These samples can be found in the following location:
  • On Windows: %DB2PATH%\sqllib\samples\xml (where %DB2PATH% is a variable that determines where DB2® database server is installed)
  • On UNIX: $HOME/sqllib/samples/xml (where $HOME is the home directory of the instance owner)

comment_icon 0 Ajax From Scratch - Jquery (Most Needed tutorial for TGMC)


What You Should Already Know

Before you start studying jQuery, you should have a basic knowledge of:
  • HTML
  • CSS
  • JavaScript

What is jQuery?

jQuery is a library of JavaScript Functions.
jQuery is a lightweight "write less, do more" JavaScript library.
The jQuery library contains the following features:
  • HTML element selections
  • HTML element manipulation
  • CSS manipulation
  • HTML event functions
  • JavaScript Effects and animations
  • HTML DOM traversal and modification
  • AJAX
  • Utilities

jQuery: The Basics

This is a basic tutorial, designed to help you get started using jQuery. If you don't have a test page setup yet, start by creating a new HTML page with the following contents:

comment_icon 0 Ajax From Scratch - Methods For sending Data to Server

We can send data to the data processing page(i.e. server) by both the GET and POST methods of a form. Both methods are used in form data handling where each one has some difference on the way they work. We will discuss some of the differences.

As you have seen there is a character restriction of 255 in the URL. This is mostly the old browsers restriction and new ones can handle more than that. But we can't be sure that all our visitors are using new browsers. So when we show a text area or a text box asking users to enter some data, then there will be a problem if more data is entered. This restriction is not there in POST method.

Friday, December 2, 2011

comment_icon 2 Ajax From Scratch - Basics



hey guys in this session we are gonna discuss about AJAX , what is it ? and how it works

lets jump into the new era of web development

1st Question is that What is AJAX ?
Ans. Everyone thinks that Ajax is a programming Language but its not true its just a balance of  XML and JavaScript

Lets Discuss in deep

AJAX = Asynchronous JavaScript and XML.

where it is used ?

comment_icon 0 HTML and CSS Tutorial

This Tutorial covers the basics of HTML & CSS  that will be pretty useful while you  are working on your
Web-Application


HTML VIDEO TUTORIAL



CSS vi

Tuesday, November 29, 2011

comment_icon 0 Unified Modeling Language ( UML ) - video Tutorial

Start From the beginning.....

info : the Tutorial is still incomplete .....i uploaded all the videos, and soon i am gonna provide download link too ....please wait 24 hr. for complete and ordered tutorial 


Select Chapter


Sunday, November 27, 2011

comment_icon 0 Installing DB2 on SUSE Linux

This session covers the following things

  • installing VMware
  • installing db2 on SUSE linux 


Thursday, November 24, 2011

comment_icon 40 Creating A simple DB2 Database Application with jsp


in this session we are going to see that How to Create A simple DB2 Database Application with JSP (java server pages) . Application which we are going to build is login form
Topics Covered :
1. creating database for an application

2.Creating A form and sending data to server

3. connection to database with jsp

Steps to Follow
1.    Create database"VOTERS"

Wednesday, November 23, 2011

comment_icon 0 RAD 7.5 Installation

This session covers That how to Install the Rational Application developer