Guest User

Untitled

a guest
Jul 14th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { Text, View, StyleSheet, ImageBackground, TextInput, TouchableOpacity, Alert } from 'react-native';
  3.  
  4. export default class Login extends Component {
  5.  
  6. static navigationOptions = {
  7. header: null
  8. };
  9.  
  10. constructor(props) {
  11.  
  12. super(props);
  13. this.state = {
  14. userName : '',
  15. userPass : ''
  16. }
  17.  
  18. }
  19.  
  20.  
  21. login = () => {
  22.  
  23. const {userName} = this.state;
  24. const {userPass} = this.state;
  25.  
  26. if(userName == '' || userPass == '') {
  27.  
  28. Alert.alert('Warning' , 'Please Insert All the Required Details !!!!');
  29.  
  30. } else {
  31.  
  32.  
  33. fetch('newjsp1.jsp', {
  34. method: 'POST',
  35. headers: {
  36. Accept: 'application/json',
  37. 'Content-Type': 'application/json'
  38. },
  39. body: JSON.stringify({
  40. name: userName,
  41. pass: userPass
  42. }),
  43. })
  44. .then(function(response) {
  45. return response.json();
  46. })
  47. .then(function(myJson) {
  48. console.log(myJson);
  49. });
  50.  
  51.  
  52. }
  53.  
  54. }
  55.  
  56.  
  57.  
  58. render() {
  59.  
  60. return (
  61. <View style={styles.container}>
  62.  
  63. <ImageBackground source={require('../img/1.jpg')} style={styles.backgroundImage}>
  64. <View style={styles.content}>
  65.  
  66. <Text style={styles.logo}> -- LOGIN DEMO -- </Text>
  67.  
  68. <View style={styles.inputContainer}>
  69. <TextInput underlineColorAndroid='transparent' style={styles.input} placeholder='USERNAME' onChangeText = {userName => this.setState({userName})} >
  70. </TextInput>
  71. <TextInput underlineColorAndroid='transparent' secureTextEntry={true} style={styles.input} placeholder='PASSWORD' onChangeText = {userPass => this.setState({userPass})} >
  72. </TextInput>
  73. </View>
  74.  
  75. <TouchableOpacity onPress={this.login} style={styles.buttonContainer}>
  76. <Text style={styles.buttonText}>LOGIN</Text>
  77. </TouchableOpacity>
  78.  
  79. </View>
  80. </ImageBackground>
  81.  
  82. </View>
  83. );
  84.  
  85. }
  86.  
  87.  
  88. }
  89.  
  90. <%
  91.  
  92. String user = request.getParameter("name");
  93. String pass = request.getParameter("pass");
  94.  
  95.  
  96. JSONObject obj = new JSONObject();
  97.  
  98. obj.put("USERNAME", user);
  99. obj.put("PASSWORD", pass);
  100.  
  101.  
  102. out.print(obj);
  103.  
  104.  
  105. %>
Add Comment
Please, Sign In to add comment